17 December 2014

How to sum data from different Excel sheets?

It is referred to as to consolidate data from multiple sheets into a master sheet.

1. Drag your mouse to select the cells corresponding to those in multiple sheets. Note: It would not work if you click the top-left corner box.
2. Date | Consolidate.
3. Click the icon under 'Reference'.
4. Go to the first data sheet, and drag-select all the cells. Click the icon again. Click 'Add'.
5. Go to the second data sheet, and repeat Step 4. Repeat until all the data sheets are done.
6. Click OK.

Done.

In addition to 'Addition', you can also do average, counting, max, min, product, etc.

16 December 2014

Chrome - In Outlook Web App, can not attach files when composing a new email

There are two solutions -

1. Checking 'Use the light version of Outlook Web App' when signing in. Will be able to attach files.

2.

http://www.c7solutions.com/2014/09/group-policy-import-to-fix-google-chrome-v37-issues-with-exchange-server-and-microsoft-crm

A recent update to Google Chrome (37.0.2062.120) removed the ability to support modal dialog boxes. This are dialogs that require your attention and stop you going back to the previous page until you have completed the info required – these are very useful in workflow type scenarios.
Google claim that as 0.004% of web sites use them (from Google anonymous statistics gathering that you can opt into in Chrome) they are justified in removing support for them – but they have not removed other things that have the same level of support!
With this version of Chrome (or the Chromium open source browser) there is a work around until April 30th 2015 that will allow modal dialogs to work again. Without this work around clicking links in OWA and ECP in Exchange 2010 and OWA and EAC in Exchange Online and Exchange 2013 will not popup. This can cause issues such as the inability to attach files in OWA and to create objects in ECP/EAC for the administrator. Popups in Microsoft CRM also do not work.
As a work around you could use a different browser, but if Chrome works for you (or does not in this case) and you are joined to a domain then you can download the following GPO export file and import it into your Active Directory to enable modal dialogs to work again in Exchange Server, Office 365 and Microsoft CRM products.
To download and import this GPO file to enable Chrome modal dialog box functionality to resume (until 30th April 2015, when Google stop allowing the work around) follow these steps:
  1. Download Google Chrome Show Modal Dialog Before 30 April 2015.zip
  2. Copy to a domain controller and expand the zip file. Ensure the contents of the zip file are not placed directly on your desktop as you cannot import from the desktop directly, so if you expand the zip to the desktop then copy the one folder that was created into a new subfolder.
  3. Start Group Policy Management MMC admin tool.
  4. Expand Forest > Domain > Your Domain > Group Policy Objects.
  5. Right click “Group Policy Objects” and choose New
  6. Create a new GPO called “Chrome and Chromium Modal Dialog Box Allow”:
    image
  7. Right click “Chrome and Chromium Modal Dialog Box Allow” GPO that you just made and choose Import Settings
  8. Proceed through the import wizard. You do not need to backup this new GPO on the second page of the dialog as the new GPO is empty.
  9. On the third page of the wizard browse to the parent folder containing the contents of the download above:
    image
  10. Click Next and you should see one backed up GPO listed:
    image
  11. Click Next to import this. If you click View Settings first a web page will open showing you that this GPO sets two registry keys for the computer and two registry keys for the user. These set SOFTWARE\Policies\Chromium\EnableDeprecatedWebPlatformFeatures and Software\Policies\Google\Chrome\EnableDeprecatedWebPlatformFeatures (for both Chromium and Chrome browsers) with a reg key (type string) 1:ShowModalDialog_EffectiveUntil20150430
  12. Proceed with Next and then Finish and the import will begin:
    image
  13. Click OK.
  14. Now link the GPO object to the root of your domain so it impacts all users and to the root of any OU that blocks inheritance. Import to other domains as above or link from this domain depending upon your current policy for managing GPO cross domains.
  15. Delete the zip and folder you downloaded. They are not needed any more.

08 December 2014

How to copy Chinese and English texts from a photo PDF file?

Adobe Acrobat
Tools | Text Recognition | In this file | Edit | Priamary OCR Language,

Choose Chinese, then English will also be OK.

24 November 2014

Can not download files in IE

Can not download a file in IE, but can download the same file in Chrome, etc.

Solution: change the extension name into .dat

30 October 2014

Ubuntu Linux Network Configuration

https://help.ubuntu.com/10.04/serverguide/network-configuration.html


Ubuntu ships with a number of graphical utilities to configure your network devices. This document is geared toward server administrators and will focus on managing your network on the command line.

Ethernet Interfaces

Ethernet interfaces are identified by the system using the naming convention of ethX, where X represents a numeric value. The first Ethernet interface is typically identified as eth0, the second as eth1, and all others should move up in numerical order.

Identify Ethernet Interfaces

To quickly identify all available Ethernet interfaces, you can use the ifconfig command as shown below.
ifconfig -a | grep eth
eth0      Link encap:Ethernet  HWaddr 00:15:c5:4a:16:5a
Another application that can help identify all network interfaces available to your system is the lshw command. In the example below, lshw shows a single Ethernet interface with the logical name of eth0 along with bus information, driver details and all supported capabilities.
sudo lshw -class network
  *-network
       description: Ethernet interface
       product: BCM4401-B0 100Base-TX
       vendor: Broadcom Corporation
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: eth0
       version: 02
       serial: 00:15:c5:4a:16:5a
       size: 10MB/s
       capacity: 100MB/s
       width: 32 bits
       clock: 33MHz
       capabilities: (snipped for brevity)
       configuration: (snipped for brevity)
       resources: irq:17 memory:ef9fe000-ef9fffff

Ethernet Interface Logical Names

Interface logical names are configured in the file /etc/udev/rules.d/70-persistent-net.rules. If you would like control which interface receives a particular logical name, find the line matching the interfaces physical MAC address and modify the value of NAME=ethX to the desired logical name. Reboot the system to commit your changes.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Ethernet Interface Settings

ethtool is a program that displays and changes Ethernet card settings such as auto-negotiation, port speed, duplex mode, and Wake-on-LAN. It is not installed by default, but is available for installation in the repositories.
sudo apt-get install ethtool
The following is an example of how to view supported features and configured settings of an Ethernet interface.
sudo ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Half 1000baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Half 1000baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Current message level: 0x000000ff (255)
        Link detected: yes
Changes made with the ethtool command are temporary and will be lost after a reboot. If you would like to retain settings, simply add the desired ethtool command to a pre-up statement in the interface configuration file /etc/network/interfaces.
The following is an example of how the interface identified as eth0 could be permanently configured with a port speed of 1000Mb/s running in full duplex mode.
auto eth0
iface eth0 inet static
pre-up /usr/sbin/ethtool -s eth0 speed 1000 duplex full
[Note]
Although the example above shows the interface configured to use the static method, it actually works with other methods as well, such as DHCP. The example is meant to demonstrate only proper placement of the pre-up statement in relation to the rest of the interface configuration.

IP Addressing

The following section describes the process of configuring your systems IP address and default gateway needed for communicating on a local area network and the Internet.

Temporary IP Address Assignment

For temporary network configurations, you can use standard commands such as ip, ifconfig and route, which are also found on most other GNU/Linux operating systems. These commands allow you to configure settings which take effect immediately, however they are not persistent and will be lost after a reboot.
To temporarily configure an IP address, you can use the ifconfig command in the following manner. Just modify the IP address and subnet mask to match your network requirements.
sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0
To verify the IP address configuration of eth0, you can use the ifconfig command in the following manner.
ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:15:c5:4a:16:5a  
          inet addr:10.0.0.100  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::215:c5ff:fe4a:165a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:466475604 errors:0 dropped:0 overruns:0 frame:0
          TX packets:403172654 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2574778386 (2.5 GB)  TX bytes:1618367329 (1.6 GB)
          Interrupt:16 
To configure a default gateway, you can use the route command in the following manner. Modify the default gateway address to match your network requirements.
sudo route add default gw 10.0.0.1 eth0
To verify your default gateway configuration, you can use the route command in the following manner.
route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth0
If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file /etc/resolv.conf. The example below shows how to enter two DNS servers to /etc/resolv.conf, which should be changed to servers appropriate for your network. A more lengthy description of DNS client configuration is in a following section.
nameserver 8.8.8.8
nameserver 8.8.4.4
If you no longer need this configuration and wish to purge all IP configuration from an interface, you can use the ip command with the flush option as shown below.
ip addr flush eth0
[Note]
Flushing the IP configuration using the ip command does not clear the contents of /etc/resolv.conf. You must remove or modify those entries manually.

Dynamic IP Address Assignment (DHCP Client)

To configure your server to use DHCP for dynamic address assignment, add the dhcp method to the inet address family statement for the appropriate interface in the file /etc/network/interfaces. The example below assumes you are configuring your first Ethernet interface identified as eth0.
auto eth0
iface eth0 inet dhcp
By adding an interface configuration as shown above, you can manually enable the interface through the ifup command which initiates the DHCP process via dhclient.
sudo ifup eth0
To manually disable the interface, you can use the ifdown command, which in turn will initiate the DHCP release process and shut down the interface.
sudo ifdown eth0

Static IP Address Assignment

To configure your system to use a static IP address assignment, add the static method to the inet address family statement for the appropriate interface in the file /etc/network/interfaces. The example below assumes you are configuring your first Ethernet interface identified as eth0. Change the address, netmask, and gateway values to meet the requirements of your network.
auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1
By adding an interface configuration as shown above, you can manually enable the interface through the ifup command.
sudo ifup eth0
To manually disable the interface, you can use the ifdown command.
sudo ifdown eth0

Loopback Interface

The loopback interface is identified by the system as lo and has a default IP address of 127.0.0.1. It can be viewed using the ifconfig command.
ifconfig lo
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2718 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2718 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:183308 (183.3 KB)  TX bytes:183308 (183.3 KB)
By default, there should be two lines in /etc/network/interfaces responsible for automatically configuring your loopback interface. It is recommended that you keep the default settings unless you have a specific purpose for changing them. An example of the two default lines are shown below.
auto lo
iface lo inet loopback

Name Resolution

Name resolution as it relates to IP networking is the process of mapping IP addresses to hostnames, making it easier to identify resources on a network. The following section will explain how to properly configure your system for name resolution using DNS and static hostname records.

DNS Client Configuration

To configure your system to use DNS for name resolution, add the IP addresses of the DNS servers that are appropriate for your network in the file /etc/resolv.conf. You can also add an optional DNS suffix search-lists to match your network domain names.
Below is an example of a typical configuration of /etc/resolv.conf for a server on the domain "example.com" and using two public DNS servers.
search example.com
nameserver 8.8.8.8
nameserver 8.8.4.4
The search option can also be used with multiple domain names so that DNS queries will be appended in the order in which they are entered. For example, your network may have multiple sub-domains to search; a parent domain of example.com, and two sub-domains, sales.example.com and dev.example.com.
If you have multiple domains you wish to search, your configuration might look like the following.
search example.com sales.example.com dev.example.com
nameserver 8.8.8.8
nameserver 8.8.4.4
If you try to ping a host with the name of server1, your system will automatically query DNS for its Fully Qualified Domain Name (FQDN) in the following order:
  1. server1.example.com
  2. server1.sales.example.com
  3. server1.dev.example.com
If no matches are found, the DNS server will provide a result of notfound and the DNS query will fail.

Static Hostnames

Static hostnames are locally defined hostname-to-IP mappings located in the file /etc/hosts. Entries in the hosts file will have precedence over DNS by default. This means that if your system tries to resolve a hostname and it matches an entry in /etc/hosts, it will not attempt to look up the record in DNS. In some configurations, especially when Internet access is not required, servers that communicate with a limited number of resources can be conveniently set to use static hostnames instead of DNS.
The following is an example of a hosts file where a number of local servers have been identified by simple hostnames, aliases and their equivalent Fully Qualified Domain Names (FQDN's).
127.0.0.1 localhost
127.0.1.1 ubuntu-server
10.0.0.11 server1.example.com server1 vpn
10.0.0.12 server2.example.com server2 mail
10.0.0.13 server3.example.com server3 www
10.0.0.14 server4.example.com server4 file
[Note]
In the above example, notice that each of the servers have been given aliases in addition to their proper names and FQDN's. Server1 has been mapped to the name vpn, server2 is referred to as mail, server3 as www, and server4 as file.

Name Service Switch Configuration

The order in which your system selects a method of resolving hostnames to IP addresses is controlled by the Name Service Switch (NSS) configuration file /etc/nsswitch.conf. As mentioned in the previous section, typically static hostnames defined in the systems /etc/hosts file have precedence over names resolved from DNS. The following is an example of the line responsible for this order of hostname lookups in the file /etc/nsswitch.conf.
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
  • files first tries to resolve static hostnames located in /etc/hosts.
  • mdns4_minimal attempts to resolve the name using Multicast DNS.
  • [NOTFOUND=return] means that any response of notfound by the preceeding mdns4_minimal process should be treated as authoritative and that the system should not try to continue hunting for an answer.
  • dns represents a legacy unicast DNS query.
  • mdns4 represents a Multicast DNS query.
To modify the order of the above mentioned name resolution methods, you can simply change the hosts: string to the value of your choosing. For example, if you prefer to use legacy Unicast DNS versus Multicast DNS, you can change the string in /etc/nsswitch.conf as shown below.
hosts:          files dns [NOTFOUND=return] mdns4_minimal mdns4

Bridging

Bridging multiple interfaces is a more advanced configuration, but is very useful in multiple scenarios. One scenario is setting up a bridge with multiple network interfaces, then using a firewall to filter traffic between two network segments. Another scenario is using bridge on a system with one interface to allow virtual machines direct access to the outside network. The following example covers the latter scenario.
Before configuring a bridge you will need to install the bridge-utils package. To install the package, in a terminal enter:
sudo apt-get install bridge-utils
Next, configure the bridge by editing /etc/network/interfaces:
auto lo
iface lo inet loopback

auto br0
iface br0 inet static
        address 192.168.0.10
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off
[Note]
Enter the appropriate values for your physical interface and network.
Now restart networking to enable the bridge interface:
sudo /etc/init.d/networking restart
The new bridge interface should now be up and running. The brctl provides useful information about the state of the bridge, controls which interfaces are part of the bridge, etc. See man brctl for more information.

Resources


Ubuntu Linux - How to install software?

https://help.ubuntu.com/12.04/serverguide/installing-from-cd.html

Installing the package groups is accomplished using the tasksel utility. One of the important differences between Ubuntu (or Debian) and other GNU/Linux distribution is that, when installed, a package is also configured to reasonable defaults, eventually prompting you for additional required information. Likewise, when installing a task, the packages are not only installed, but also configured to provided a fully integrated service.
Once the installation process has finished you can view a list of available tasks by entering the following from a terminal prompt:
 
tasksel --list-tasks
The output will list tasks from other Ubuntu based distributions such as Kubuntu and Edubuntu. Note that you can also invoke the tasksel command by itself, which will bring up a menu of the different tasks available.
You can view a list of which packages are installed with each task using the --task-packages option. For example, to list the packages installed with the DNS Server task enter the following:
 
tasksel --task-packages dns-server
The output of the command should list:
 
bind9-doc 
bind9utils 
bind9
If you did not install one of the tasks during the installation process, but for example you decide to make your new LAMP server a DNS server as well, simply insert the installation CD and from a terminal:
 
sudo tasksel install dns-server

22 October 2014

Can Not Log On

`you cannot logon because the logon method you are using is not allowed on this computer windows 7'

Solution:

https://social.technet.microsoft.com/Forums/windows/en-US/0f750de8-d56e-4951-a2b1-839e55934745/non-admin-users-cannot-logon-to-the-domain-on-windows-7-wks?forum=w7itpronetworking

Symptom: When trying to logon a computer using non administrator ID, you may receive this message: "You cannot log on because the logon method you are using is not allowed on this computer. Please see you network administrator for more details."
Case 1: Group Policy' "Allow log on locally" was not setup to allow users or domain users. To setup allow users or domain users to logon the computer or domain, you need to add the users or domain users to the "Allow log on locally". Please follow these steps to add the users.

1. Run gpedit.msc.
2. Expand Windows Settings\Security Settings\Local Policies
3. Click on User Rights Assignment
4. Ensure that "Allow log on locally" includes Administrators, Backup
Operators, Domain Users or Users.

Case 2: Group Policy' "Deny log on locally"  was setup to deny users or domain users. To setup allow users or domain users to logon the computer or domain locally, "Deny log on locally" should be empty or no users or domain users in the list. Please follow these steps to remove the users or domain users from the "Deny log on locally".

1. Run gpedit.msc.
2. Expand Windows Settings\Security Settings\Local Policies
3. Click on User Rights Assignment
4. Ensure that "Deny log on locally" is empty.

Case 3: The local group policy allow user to logon. However, domain group policy which overrides local policy doesn't allow users to logon locally. The resolution is modify the domain policy to allow users to logon locally.

Case 4:  The domain policy allows domain users to logon locally, but the local policy doesn't and the domain policy doesn't apply to the computer. The fix is running gpupdate to force to update the domain policy.
Case 5: Norton Firewall blocks the communication between the client and domain controller. The solution is disabling Norton firewall or re-configuring it to allow to access the domain controller.

MCSE, MCSA, MCDST [If this post helps to resolve your issue, please click the "Mark as Answer" or "Helpful" button at the top of this message. By marking a post as Answered, or Helpful you help others find the answer faster.]

20 October 2014

how to synchronize time in windows 7

http://technet.microsoft.com/en-us/library/cc758905(WS.10).aspx

Administrative Credentials
To perform this procedure, you must be a member of the Administrators group on the local computer. To perform this procedure from a remote computer, you must be a member of the Domain Admins group.

To configure a client computer for automatic domain time synchronization

  1. Open a Command Prompt.
  2. Type the following command and then press ENTER:
    w32tm /config /syncfromflags:domhier /update
  3. Type the following command and then press ENTER:
    net stop w32time
  4. Type the following command and then press ENTER:
    net start w32time

29 September 2014

Definitive Guide: Factory Reset Brother HL-2170W Wireless Printer

http://binglongx.wordpress.com/2013/06/23/definitive-guide-factory-reset-brother-hl-2170w-wireless-printer/

The little printer was easy to set up initially, see a previous post. However, Brother does not have very good configuration support if anything changes in the wireless network, for example, your wireless router, SSID or key. Supposedly you just need to re-connect the Ethernet cable, and re-run Wireless Setup Wizard for Windows to let the printer know your new wireless network information, and restore printing. What you may often see, however, is that the Wizard reports it could not find the printer at all, letting alone allowing you to change its configuration.
The problem is that the printer is stuck with the stale network information and even prevents configuration connections. Whenever the PC cannot see the printer, the recommended approach is to factory reset the printer and redo the setup process. You can find the official factory reset instructions here. However, the instructions are too concise and do not tell you what is normal and what is not during the process, and you could wonder if you did it right. I stumbled a few times on that. By combining the official instructions with Brother HL-2170W: Installation Gotchas + Reset to Factory Settings and How do I configure the wireless printer with the temporary use of a network cable and install the printer driver in Windows, and after some experiments, I believe below is the best guide available over the internet for factory resetting Brother HL-2170W:
  1. Turn off the printer.
  2. Remove the Ethernet cable and USB cable from the printer.
  3. Remove paper from printer and close the front cover. Removing paper is optional and to save paper and toner; if you go wrong, the printer may print TEST PRINT pages, which I have had a bunch…
  4. Hold the Go button and turn on the printer. In fact the Go button is the only button that you can operate. It is white, and has blue light when on.
  5. Keep the Go button pressed down until the Toner, Drum and Error LEDs light up. For my printer, as soon as I power up the printer all the three LEDs light on immediately.
  6. Release the Go button and make sure the Toner, Drum and Error LEDs go off. Again, for my printer, the three LEDs go off right after I release the Go button. At this time, all the LEDs and the Go button light are off.
  7. Press (and of course release) the Go button 7 times. When the Go button is pressed, its blue light is on. After 7 presses, all the LEDs and the Go button light are off. For a few seconds, the printer may not seem to respond to your presses at all. Don’t worry, I believe it is just unsure and waiting for you to press more if you want to do some other secret settings. For example, pressing Go more times can print the TEST PRINT page.
  8. After the waiting period (for my printer this silence takes about 10 seconds), all the Toner, Drum and Error LEDs and the Go button light come on briefly and go off, then the Go button light slowly flashes for a few times. This means the factory reset is successful.
  9. After the factory reset, as you usually see when the printer is turned on, it makes some noise and then the Go button remain lit. The printer is now ready.
If you believe you go wrong in the middle, just turn off the printer and start over. The procedure above could be too much for first time users. In my point of view, since any change in network settings essentially requires resetting the wireless printer, Brother could have really added a reset button in the back of the printer and made it painless.
Once your printer is reset, you can use an Ethernet cable to connect it to your home network. If your router has a DHCP server, HL-2170W will try to get an IP there. The instructions say that you may need to wait for 1 minute, but I can see that the printer gets an IP right away from my router in the router’s management page. It is also shown that the printer names itself as BRNxxxxxxxxxxxxxx in the DHCP client list.
Now you just need to run Wireless Setup Wizard for Windows, and it will see the printer with the BRNxxxxxxxxxxxxxx host name and IP from DHCP. You just need to follow the rest of Installing Brother HL-2170W Wireless Laser Printer to finish the installation.

09 July 2014

How to put online form data in a table, before sending it to an email address?

<?php
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
?>

Chinese displayed as gibberish

To correctly display Chinese, 4 things should be done –

1. When creating the database, Chinese should be defined –

create database dbsettle character set 'gbk' collate 'gbk_chinese_ci';

use dbsettle;

2. On the web page, in the header section, Chinese should be defined –

<meta http-equiv="content-type" content="charset=gbk" />

3. In the programme code, after having connected to the database, Chinese should be defined –

mysql_select_db("dbsettle",$db);

mysql_query("set names gbk", $db);

4. In the sending email section of the code, content type should be defined –

// Always set content-type when sending HTML email

$headers = "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type:text/html;charset=gbk" . "\r\n";

// More headers

$headers .= 'From: xxxx@cicscanada.com' . "\r\n";

// $headers .= 'Cc: myboss@example.com' . "\r\n";

        // send mail

        mail($to, $subject, $message, $headers)

If all the above is done, then Chinese will correctly be displayed in the email.

How to automatically send an online form to an email address with PHP?

Define SMTP (e.g. Bell) and Port in php.ini.
Use mail function of PHP.

30 June 2014

Fixed-width email or e-newsletter (example)



<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td bgcolor="#D98200">&nbsp;</td>
    <td bgcolor="#D98200" style="width:600px">&nbsp;</td>
    <td bgcolor="#D98200">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D98200" style="border-bottom: solid 2px #d98200">&nbsp;</td>    <!--Without this border-bottom style, there would be a white line at the bottom of this first column, because the second column has a 2px border in colour #c17402 -->
    <td style="width:600px; border-right: outset 2px #c17402; border-bottom: outset 2px #c17402">
        <table width="600px" border="0" cellspacing="0" cellpadding="5" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size: 12px">
              <tr>
                <td>CONTENTS</td>   <!--Contents of e-newsletter is actually here-->
              </tr>
        </table></td>
    <td bgcolor="#D98200" style="border-bottom: solid 2px #d98200">&nbsp;</td>    <!--Without this border-bottom style, there would be a white line at the bottom of this third column, because the second column has a 2px border in colour #c17402 -->
  </tr>
  <tr>
    <td bgcolor="#D98200">&nbsp;</td>
    <td bgcolor="#D98200" style="width:600px">&nbsp;</td>
    <td bgcolor="#D98200">&nbsp;</td>
  </tr>
</table>


Wrap text around an image with CSS

http://www.homeandlearn.co.uk/WD/wds4p6.html

Let's see how to get the following style:
Browser showing text wrapped around an image
As you can see, the image is on the right and the text flows around it. There is also space between the image and the text.
The first thing to do is to set up a STYLE in the HEAD section of the HTML. Add the highlighted code to your own HTML:
CSS style for text wrapping
The style we've set up is called TextWrap. In between the two curly brackets we have this:
float: right;
margin: 10px;
The CSS property we need in order to move the image is called float. The float property can take three values: left, right and none. To get some space between the image and the text we can use the margin property. We've set it to 10 pixels. This will give you space around the entire image. If you only want space on specific sides of the image you can use these:
margin-left
margin-right
margin-top
margin-bottom
So we could have done this:
margin-left: 10px;
margin-bottom: 10px;
That would get us a 10 pixels margin on the left of the image and 10 pixels at the bottom.
To apply the style to the image, you need to add the CLASS attribute to the IMG tag:
<IMG SRC="york_images/york_minster_2.gif" CLASS="TextWrap">
The CLASS attribute doesn't have to go at the end. If you prefer, you can put it after the IMG tag:
<IMG CLASS="TextWrap" SRC="york_images/york_minster_2.gif" >
Just take note of where all the spaces are in the code above.
Amend your own IMG tag and add CLASS="TextWrap" to your own IMG code. Before you try it out, add a paragraph of text below the image:
<IMG class="TextWrap" SRC="york_images/york_minster_2.gif">
<P>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at ante. Mauris eleifend, quam a vulputate dictum, massa quam dapibus leo, eget vulputate orci purus ut lorem. In fringilla mi in ligula. Pellentesque aliquam quam vel dolor. Nunc adipiscing. Sed quam odio, tempus ac, aliquam molestie, varius ac, tellus. Vestibulum ut nulla aliquam risus rutrum interdum. Pellentesque lorem. Curabitur sit amet erat quis risus feugiat viverra.
</P>
You can, of course, use your own text, and not just the Lorem ipsum text. Make sure your IMG code is above the first P tag, however.
Save your work and view the results in your browser.
There is, however, a problem with the above code. Suppose we want a second paragraph of text with another image floated on the left. We want to do this:
Browser showing text wrapped around two images
Here, the second image is nicely aligned below and to the left of the first image. The text is in the right place, too.
To achieve this, you might think of adding a second style and then applying it to the second image. Like this:
CSS code that wraps text to the left and right of two images
In the second style, we've used float: left and added a 10 pixel margin as before. In the second IMG tag, we've used the new TextWrapLeft class.
However, saving the work and refreshing gives you this in the browser:
Browser showing badly aligned text wrapping
In this version, the second image starts two thirds of the way down the first image. The text doesn't flow as we want it, as well.
The way to correct this is to use a CSS property called clear. This clears any floating elements and gets you back to the normal, default flow for browsers. The clear property can take four values: left, right, both, none. Because our first image was floated to the right, we want to clear to the right. We can add this to the second style:
CSS code that clears text wrapping
If our first image had been on the left, we would have used clear: left.

10 June 2014

SysAid Old Service Requests Not Show Up



Problem: After I re-installed SysAid, old service requests were all gone.
Solution: When I re-installed SysAid, I created a new database named 'SysAid'. But I saw that there were two databases within MS SQL Server Management Studio. One was 'SysAid', the other 'SysAid_cics'. I knew that our former database name was 'SysAid_cics'. I changed the database name in 'Program Files\SysAid Server\root\WEB-INF\conf\ServerConf.xml' from SysAid into SysAid_cics. Problem is gone.

Error when installing Adobe Reader

Update Microsoft .Net Framework, then you will be successful installing Adobe Reader.

21 May 2014

SysAid server service can not be started

Edit the file ‘C:\Program Files\SysAidServer\conf\wrapper.conf

wrapper.java.maxmemory=1024 (Mr Kobi Versano of SysAid changed this from 2048 into 1024)
The SysAid server service then can be started.

19 February 2014

Flash drive partition tool - only part of disk is shown

Download software - Microsoft DiskPart - from

http://www.softpedia.com/progDownload/DiskPart-Download-207653.html

1) Type "DISKPART" from the Command Prompt (accessible by clicking on Start and then typing "cmd" into the open field); you will then see the following prompt: DISKPART>
2) Type "LIST DISK" to see what number your USB drive is listed as.
3) Type "SELECT DISK 2" (if your USB is disk 2; replace # with your disk #); Diskpart will confirm that "Disk 2 is now the select disk."
4) Type "SELECT PARTITION 1" (this command selects what should be the only partition on your USB drive, the small one that you want to delete to get back the larger, full partition size). Diskpart will confirm with "Partition 1 is now the selected partition."
5) Type "DELETE PARTITION". This will delete the old partition. There are no warning prompts if you have existing data - make sure you have copied everything off before doing this!
6) Type "CREATE PARTITION PRIMARY" to create a new, full-size partition. Diskpart will confirm with message of "Diskpart succeeded in creating the specified partition." You can type in "LIST PARTITION" to confirm the new, full-size.
7) Type "EXIT" to leave Diskpart. You can now format your USB drive by using the standard Windows formatting process.

  1. DiskPart
  2. List Disk
  3. Select Disk #
  4. Clean
  5. Create Partition Primary
  6. Select Partition 1
  7. Active
  8. Format fs=FAT32 quick
  9. Assign

29 January 2014

How to change physical path of a website in IIS?

In IIS Manager,
Sites | Default Website, right-click, choose Manage Website | Advanced Settings... | Physical Path.

Configuring FastCGI to Host PHP Applications (IIS 7)

http://technet.microsoft.com/en-us/library/dd239230%28v=ws.10%29.aspx

20 out of 33 rated this helpful - Rate this topic
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
Internet Information Services (IIS) 7.0 adds support for the FastCGI protocol, which improves the performance and reliability of popular application frameworks, such as PHP, hosted on an IIS Web server. FastCGI provides a high-performance alternative to the Common Gateway Interface (CGI) protocol, a standard way of interfacing external applications with Web servers.
IIS 7 for Windows Server® 2008 and Windows Vista® with Service Pack 1 (SP1) now include a built-in FastCGI component. This topic describes how to use the FastCGI module to host PHP applications on IIS 7 in Windows Server 2008 and Windows Vista with SP1.
Important: This topic provides instructions about how to install and how to use the FastCGI component on Windows Server 2008 and Windows Vista with SP1. There is no officially supported FastCGI component for Windows Vista (not SP1). It is strongly recommended that you upgrade to Windows Vista with SP1 if you have to use the FastCGI component on the Windows Vista operating system.
  1. Open Server Manager.
  2. In the right pane, under Roles Summary, click Add Roles.
  3. Use the Add Roles Wizard to select the CGI role service. This enables both the CGI and FastCGI services.
  1. Go to the Windows Start menu, and open the Control Panel.
  2. Double-click Programs and Features.
  3. Click Turn Windows features on or off.
  4. In the Windows Features dialog box, expand Internet Information Services, expand World Wide Web Services, expand Application Development Features, and then select CGI. Click OK.
  5. Install the update for the FastCGI module from one of the following locations. This update fixes several known compatibility issues with popular PHP applications.
It is recommended that you use a non-thread-safe build of PHP with IIS 7 FastCGI. A non-thread-safe build of PHP provides significant performance gains over the standard build by not doing any thread-safety checks. These checks are not necessary because FastCGI guarantees a single-threaded execution environment.
  1. Go to the PHP Web site and download the latest non-thread-safe binaries of PHP.
  2. Unzip the files to a directory of your choice, for example, C:\PHP. Rename the Php.ini-recommended to Php.ini
  3. Open the Php.ini file, and then uncomment and modify the settings as follows:
    1. Set fastcgi.impersonate = 1. FastCGI in IIS supports the ability to impersonate the security tokens of the calling client. This allows IIS to define the security context under which the request runs.
    2. Set cgi.fix_pathinfo=1. cgi.fix_pathinfo provides actual PATH_INFO/PATH_TRANSLATED support for CGI. Previous PHP behavior was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to ignore that setting in PATH_INFO. For more information about PATH_INFO, see the CGI specifications. Setting the PATH_INFO value to 1 will cause PHP CGI to match its paths to the specification.
    3. Set cgi.force_redirect = 0.
    4. Set open_basedir to point to a folder or network path where the content of the Web site is located.
  4. To test whether the PHP installation is successful, type the following at a command prompt:
    C:\PHP>php –info
    If PHP was installed correctly and all its dependencies are available on the computer, then this command will output the current PHP configuration information.
For IIS 7 to host PHP applications, you must add a handler mapping that tells IIS to pass all requests for PHP files to the PHP application framework using the FastCGI protocol.
  1. Open IIS Manager, and then move to the server level.
  2. Double-click Handler Mappings.
  3. In the Actions pane, click Add Module Mapping.
  4. In the Add Module Mapping dialog box, specify the configuration settings as follows:
    • Request path: *.php
    • Module: FastCgiModule
    • Executable: C:\[Path to your PHP installation]\php-cgi.exe
    • Name: PHPviaFastCGI
  5. Click OK.
  6. In the dialog box that asks you to confirm that you want to create a FastCGI application for the executable, click Yes.
  7. To verify that the handler mapping works correctly, create a Phpinfo.php file in the C:\inetpub\wwwroot folder that contains the following:
    <?php phpinfo(); ?>
  8. Open a Web browser, and then navigate to http://localhost/phpinfo.php. If everything was set up correctly, you will see the standard PHP information page.
You can also use Appcmd.exe to add a handler mapping.
  1. To create a FastCGI application process pool, run the following command:
    C:\>%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCgi /+[fullPath='c:\{php_folder}\php-cgi.exe']
  2. To create the handler mapping, run the following command:
    C:\>%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:\{php_folder}\php-cgi.exe',resourceType='Either']
    Note: If you are using PHP version 4.x, instead of Php-cgi.exe, you can use Php.exe.
Make sure that FastCGI always recycles Php-cgi.exe processes before native PHP recycling starts. The configuration property instanceMaxRequests controls the FastCGI process-recycling behavior. This property specifies how many requests FastCGI will process before recycling. PHP also has a similar process-recycling functionality that is controlled by the environment variable PHP_FCGI_MAX_REQUESTS. By setting instanceMaxRequests to a value that is smaller than or equal to PHP_FCGI_MAX_REQUESTS, you can make sure that the native PHP process-recycling logic will never start.
To set these configuration properties, use the following commands:
C:\>%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /[fullPath='c:\{php_folder}\php-cgi.exe'].instanceMaxRequests:10000
C:\>%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /+[fullPath='c:\{php_folder}\php-cgi.exe'].environmentVariables.[name=’PHP_FCGI_MAX_REQUESTS’, value='10000']
Note: If these parameters have not been set, the following default settings will be used (on most PHP builds): instanceMaxRequests = 200, PHP_FCGI_MAX_REQUESTS = 500.

How to Install PHP on IIS 7 for Windows Server 2008

http://www.howtogeek.com/50432/how-to-install-php-on-iis-7-for-windows-server-2008/

One of most popular development platforms on the web is PHP which powers many popular applications and sites such as Facebook, WordPress and Joomla. While most of these systems are ‘designed’ to be used on a Linux system running the Apache Web Server, you can deploy PHP applications via IIS 7 on your Windows Server 2008 system.

Configuring PHP

In order for Windows to run PHP code, the PHP binary files need to be copied to your system. No installation is required, however some configuration must be done in order for it to properly run. The first step is to download the PHP Windows Binaries and extract them (i.e. ‘C:PHP’). For IIS 7, the non thread safe binaries should be used.
image
Copy the ‘php.ini-production’ file from the extracted files paste it into the Windows directory. In the Windows directory, rename this file to ‘php.ini’.

Open the ‘php.ini’ file in Notepad and configure it as needed. Out of the box, the production configuration we copied is preconfigured for what the PHP Team feels is good for a production server. There are a few changes you will need to make to configure PHP for your IIS 7 system:
  • Uncomment and set the key, cgi.force_redirect = 0
  • Uncomment the key, fastcgi.impersonate = 1
  • Uncomment and set the key, extension_dir to the ‘ext’ folder in the path PHP was extracted to (i.e. ‘C:PHPext’).
  • Set the key, date.timezone to the time zone of your server (the URL on the line above this key lists the accepted values).
At this point, your Windows system can run PHP scripts from the command line using the ‘php.exe’ tool.

Configuring IIS 7 to Run FastCGI

Internet Information Services (IIS) 7 includes the FastCGI framework as part of the installation package. To make sure it is enabled in your IIS 7 installation, check the Role Services under Server Manager > Roles > Web Server.

Make sure the “CGI” option is installed under the “Application Development” section. If it is not, enable this feature and update your IIS 7 installation.

Once IIS is set, install the IIS 7 Administration Pack. If you do not use the “Typical” setup then make sure you have the “FastCGI” option set to install. This package installs the FastCGI configuration interface inside the IIS Manager.

Configuring IIS to Run PHP via FastCGI

Once IIS 7 is setup with all the required features, we just need to configure it to run PHP. First, we configure FastCGI to work with PHP under the “FastCGI Settings” option (this feature is installed as part of the IIS 7 Administration Pack).

In the FastCGI Settings screen, add an application.

Set the path to the ‘php-cgi.exe’ executable located in the folder where you extracted the PHP Windows binaries. Additionally, change the “InstanceMaxRequests” to a value higher than the default (i.e. 5000). Under the “EnvironmentVariables” setting, click the ellipses button to configure additional options.

Add a new variable named “PHP_MAX_REQUESTS” and set the value to the same amount as the “InstanceMaxRequests” setting above.

Apply all settings until you get back to the primary IIS Manager screen.
Next, we have to map how PHP scripts are executed by IIS which is configured in “Handler Mappings”.

In the Handler Mappings, add a new module mapping.

Set the module’s request path to PHP files (*.php) with the module interface “FastCgiModule”. Set the executable to the same file as what was configured in the FastCGI settings above. Assign a friendly name to this mapping, such as PHP, and click Ok.

When you get the confirmation prompt, answer “Yes” to confirm you want PHP to run as a FastCGI application.

Apply all your changes, close and restart IIS to make sure the new settings take effect.

Once this is done, there is a Microsoft hotfix available (a link is available in the links section) which addresses some issues with PHP when running under IIS 7. These should be installed on your web server to ensure PHP functions properly through FastCGI.

Testing PHP

At this point, your server is ready to go, but just to be sure we can confirm your PHP setup through IIS pretty easily. Create a text file in the directory ‘C:Inetpubwwwroot’ named ‘phpinfo.php’ which simply contains the line:
<?php phpinfo(); ?>

Finally, browse to the address: ‘http://localhost/phpinfo.php’ on your server and you should see the PHP information page. If the page loads successfully, PHP is now up and running on your machine.

Conclusion

Once you have PHP up and running on your Windows system, you can take advantage of the multitude of PHP based applications available as well as develop and deploy your own.

Links

Download PHP Windows Binaries (non thread safe)
Download IIS 7 Administration Pack
Download PHP Hotfix for IIS 7 FastCGI (x86 / x64)