WHMCS Module recieving SMS notification on new Order or Ticket

Posted by Simson on February 22nd, 2009

This Module has been tested on WHMCS 3.8.1

First of all you are going to need SMS gateway through HTTP so here i pick Clickatell, and make sure you have working WHMCS on your server

1. first create a file on your WHMCS root directory and named it whatever you want. lets say sms_api.php
and use this code or download files that you need here
http://rapidshare.com/files/197247882/sms.zip : <?php /** * Main SMS-API class

class sms {

/** YOU WILL NEED TO EDIT VARIABLE BELOW
*/
var $api_id = “”;

/**
* Clickatell username
* @var mixed
*/
var $user = “”;

/**
* Clickatell password
* @var mixed
*/
var $password = “”;

/** END OF EDITING
*/

/**
* Use SSL (HTTPS) protocol
* @var bool
*/
var $use_ssl = false;

/**
* Define SMS balance limit below class will not work
* @var integer
*/
var $balace_limit = 0;

/**
* Gateway command sending method (curl,fopen)
* @var mixed
*/
var $sending_method = “curl”;

/**
* Does to use facility for delivering Unicode messages
* @var bool
*/
var $unicode = false;

/**
* Optional CURL Proxy
* @var bool
*/
var $curl_use_proxy = false;

/**
* Proxy URL and PORT
* @var mixed
*/
var $curl_proxy = “http://127.0.0.1:8080″;

/**
* Proxy username and password
* @var mixed
*/
var $curl_proxyuserpwd = “login:secretpass”;

/**
* Callback
* 0 – Off
* 1 – Returns only intermediate statuses
* 2 – Returns only final statuses
* 3 – Returns both intermediate and final statuses
* @var integer
*/
var $callback = 0;

/**
* Session variable
* @var mixed
*/
var $session;

/**
* Class constructor
* Create SMS object and authenticate SMS gateway
* @return object New SMS object.
* @access public
*/
function sms () {
if ($this->use_ssl) {
$this->base = “http://api.clickatell.com/http”;
$this->base_s = “https://api.clickatell.com/http”;
} else {
$this->base = “http://api.clickatell.com/http”;
$this->base_s = $this->base;
}

$this->_auth();
}

/**
* Authenticate SMS gateway
* @return mixed “OK” or script die
* @access private
*/
function _auth() {
$comm = sprintf (“%s/auth?api_id=%s&user=%s&password=%s”, $this->base_s, $this->api_id, $this->user, $this->password);
$this->session = $this->_parse_auth ($this->_execgw($comm));
}

/**
* Query SMS credis balance
* @return integer number of SMS credits
* @access public
*/
function getbalance() {
$comm = sprintf (“%s/getbalance?session_id=%s”, $this->base, $this->session);
return $this->_parse_getbalance ($this->_execgw($comm));
}

/**
* Send SMS message
* @param to mixed The destination address.
* @param from mixed The source/sender address
* @param text mixed The text content of the message
* @return mixed “OK” or script die
* @access public
*/
function send($to=null, $from=null, $text=null) {

/* Check SMS credits balance */
if ($this->getbalance() < $this->balace_limit) {
die (“You have reach the SMS credit limit!”);
};

/* Check SMS $text length */
if ($this->unicode == true) {
$this->_chk_mbstring();
if (mb_strlen ($text) > 210) {
die (“Your unicode message is too long! (Current lenght=”.mb_strlen ($text).”)”);
}
/* Does message need to be concatenate */
if (mb_strlen ($text) > 70) {
$concat = “&concat=3″;
} else {
$concat = “”;
}
} else {
if (strlen ($text) > 459) {
die (“Your message is too long! (Current lenght=”.strlen ($text).”)”);
}
/* Does message need to be concatenate */
if (strlen ($text) > 160) {
$concat = “&concat=3″;
} else {
$concat = “”;
}
}

/* Check $to and $from is not empty */
if (empty ($to)) {
die (“You not specify destination address (TO)!”);
}
if (empty ($from)) {
die (“You not specify source address (FROM)!”);
}

/* Reformat $to number */
$cleanup_chr = array (“+”, ” “, “(“, “)”, “\r”, “\n”, “\r\n”);
$to = str_replace($cleanup_chr, “”, $to);

/* Send SMS now */
$comm = sprintf (“%s/sendmsg?session_id=%s&to=%s&from=%s&text=%s&callback=%s&unicode=%s%s”,
$this->base,
$this->session,
rawurlencode($to),
rawurlencode($from),
$this->encode_message($text),
$this->callback,
$this->unicode,
$concat
);
return $this->_parse_send ($this->_execgw($comm));
}

/**
* Encode message text according to required standard
* @param text mixed Input text of message.
* @return mixed Return encoded text of message.
* @access public
*/
function encode_message ($text) {
if ($this->unicode != true) {
//standard encoding
return rawurlencode($text);
} else {
//unicode encoding
$uni_text_len = mb_strlen ($text, “UTF-8″);
$out_text = “”;

//encode each character in text
for ($i=0; $i<$uni_text_len; $i++) {
$out_text .= $this->uniord(mb_substr ($text, $i, 1, “UTF-8″));
}

return $out_text;
}
}

/**
* Unicode function replacement for ord()
* @param c mixed Unicode character.
* @return mixed Return HEX value (with leading zero) of unicode character.
* @access public
*/
function uniord($c) {
$ud = 0;
if (ord($c{0})>=0 && ord($c{0})<=127)
$ud = ord($c{0});
if (ord($c{0})>=192 && ord($c{0})<=223)
$ud = (ord($c{0})-192)*64 + (ord($c{1})-128);
if (ord($c{0})>=224 && ord($c{0})<=239)
$ud = (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
if (ord($c{0})>=240 && ord($c{0})<=247)
$ud = (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
if (ord($c{0})>=248 && ord($c{0})<=251)
$ud = (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
if (ord($c{0})>=252 && ord($c{0})<=253)
$ud = (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
if (ord($c{0})>=254 && ord($c{0})<=255) //error
$ud = false;
return sprintf(“%04x”, $ud);
}

/**
* Spend voucher with sms credits
* @param token mixed The 16 character voucher number.
* @return mixed Status code
* @access public
*/
function token_pay ($token) {
$comm = sprintf (“%s/http/token_pay?session_id=%s&token=%s”,
$this->base,
$this->session,
$token);

return $this->_execgw($comm);
}

/**
* Execute gateway commands
* @access private
*/
function _execgw($command) {
if ($this->sending_method == “curl”)
return $this->_curl($command);
if ($this->sending_method == “fopen”)
return $this->_fopen($command);
die (“Unsupported sending method!”);
}

/**
* CURL sending method
* @access private
*/
function _curl($command) {
$this->_chk_curl();
$ch = curl_init ($command);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER,0);
if ($this->curl_use_proxy) {
curl_setopt ($ch, CURLOPT_PROXY, $this->curl_proxy);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $this->curl_proxyuserpwd);
}
$result=curl_exec ($ch);
curl_close ($ch);
return $result;
}

/**
* fopen sending method
* @access private
*/
function _fopen($command) {
$result = ”;
$handler = @fopen ($command, ‘r’);
if ($handler) {
while ($line = @fgets($handler,1024)) {
$result .= $line;
}
fclose ($handler);
return $result;
} else {
die (“Error while executing fopen sending method!Please check does PHP have OpenSSL support and check does PHP version is greater than 4.3.0.”);
}
}

/**
* Parse authentication command response text
* @access private
*/
function _parse_auth ($result) {
$session = substr($result, 4);
$code = substr($result, 0, 2);
if ($code!=”OK”) {
die (“Error in SMS authorization! ($result)”);
}
return $session;
}

/**
* Parse send command response text
* @access private
*/
function _parse_send ($result) {
$code = substr($result, 0, 2);
if ($code!=”ID”) {
die (“Error sending SMS! ($result)”);
} else {
$code = “OK”;
}
return $code;
}

/**
* Parse getbalance command response text
* @access private
*/
function _parse_getbalance ($result) {
$result = substr($result, 8);
return (int)$result;
}

/**
* Check for CURL PHP module
* @access private
*/
function _chk_curl() {
if (!extension_loaded(‘curl’)) {
die (“This SMS API class can not work without CURL PHP module! Try using fopen sending method.”);
}
}

/**
* Check for Multibyte String Functions PHP module – mbstring
* @access private
*/
function _chk_mbstring() {
if (!extension_loaded(‘mbstring’)) {
die (“Error. This SMS API class is setup to use Multibyte String Functions module – mbstring, but module not found. Please try to set unicode=false in class or install mbstring module into PHP.”);
}
}

}

?>

After you edit three variables above that you have gotten from Clickatell, now you need to edit 1 file WHMCS includes/actionhooks.php

add these code right after this line # $vars["Domains"] – Array of Domain IDs from Order require_once ("smsku.php"); $mysms = new sms(); $vars['Products']); $message = "Invoice: " . $vars['InvoiceID'] . ".\n Domains: " . implode(', ', $vars['Domains']) . ".\n Products: " . implode(', ', $vars['Products']); $mysms->send ("32484629030", "Order Hosting", "$message");

you will need to edit Phone number on $mysms->send (“32484629030″, “Order Hosting”, “$message”); to which number you want the sms to be sent make sure you add country code without “+”

Well give a shoot! if you need my help on making this i would give this support just contact me on Live messenger

Yahoo : indonix
Msn : simson_lai1982(at)hotmail.com

Create USB install for Ubuntu

Posted by Simson on February 22nd, 2009

If you don’t fancy carrying the delicate Ubuntu installation CD around with you, you can copy its contents to a USB key stick and use that to install Ubuntu onto computers (provided those computers can boot from USB, and most modern computers will be able to).

This is also a handy way of creating a portable USB installation of Ubuntu on a small USB key (ie 1/2GB) for use on other computers. The only problem is that the system software can’t be updated, and you’ll always be running as root user, because that’s how the live distro mode
of the install CD operates.

This tip is only relevant for users of Ubuntu 8.04 (Hardy Heron) or below. Ubuntu 8.10 (Intrepid Ibex) has built-in tools to install to create an installer USB key stick.

To make the process easier, a member of the Ubuntu community created the fantastic Liveusb software that will entirely automate the creation of a USB install stick. To install it, first add his software repository – click System → Administration → Software Sources, select the Third-
Party Software in the window that appears, and then click the Add button. Then type the following into the APT line text field:

deb http://ppa.launchpad.net/probono/ubuntu hardy main

Click OK, then the Close button in the parent dialog box, and then click to reload the list of packages when prompted. Then use Synaptic to search for and install liveusb. You’ll be told the package isn’t authenticated but this is fine.

Insert the USB stick, insert your Ubuntu install CD, and then start the program by clicking System → Administration → Install Live USB. In the Options section, you can select to install Flash Player on the USB stick, and also whether you want to make the USB stick “persistent”,
which is to say, any files you save after booting from it will stick around, rather than being wiped each boot.

Note that a bug in the Ubuntu 8.04 Hardy Heron installation CD means that it is impossible to activate persistent mode on the USB key stick. This has been fixed in the Ubuntu 8.04.1 install CD.

Ugrading debian Etch to Lenny

Posted by Simson on February 22nd, 2009

I’m upgrading my Debian Linux VM’s to their testing release, called Lenny. The upgrade itself is fairly easy and fool-proof, but installing the VMware Tools (110271) is a harder thing to do.

Upgrading Etch to Lenny (source): 1. edit /etc/apt/sources.list. Replace all occurences of ‘etch’ with ‘lenny’ 2. Run apt-get update 3. Run apt-get dist-upgrade (twice!) 4. Reboot 5. Install the kernel headers for your new kernel.
VMware Tools failed to build vmmemtcl module

When running vmware-configure.pl, I first got an error stating that the kernel was built using gcc 4.1.3, but the system was configured to use gcc 4.3.2. I needed to execute the following command to resolve that problem: ‘export CC=/usr/bin/gcc-4.1′. After that, the perl script did executed normally. On building the kernel modules, the vmmemctl module couldn’t be built correctly, exiting with an error about get_info. After a lot of Googling, I discovered that the error I was getting (see screenshot) wasn’t related to the VMware Tools at all, but was caused by the 2.6.26 kernel I was using.

The get_info method has been removed in the 2.6.26 kernel. Hence, the VMware Tools (at least the vmmemctl module) cannot be installed. Other modules in the VMware Tools did not have any problem being compiled.

I started a thread on the VMware Forum to ask for help. Gagravarr pointed out that the VMware Tools (116503) packaged with VMware Server 2 would install fine. I’ve downloaded the linux .tar.gz package, as it is the simplest way to extract the needed linux.iso file.The file can be found at vmware-server-distrib/lib/isoimages/linux.iso. Extract the file, and mount it inside your VM as you would do with usual ISO’s.Do not use ‘Install/Upgrade VMware Tools’, as this will mount the original version.

Following the usual installation steps, everything installed as expected. I now have Debian Lenny with kernel 2.6.26 (and thus paravirtualization!) and the VMware Tools running fine!

This entry was posted on Monday, October 6th, 2008 at 17:21 and is filed under Blogs. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
2 Responses to “Debian Lenny & VMware Tools”

Upgrading VMware Server on PTM Group Successfull

Posted by Simson on February 22nd, 2009


I have just Upgraded Vmware server to version 2.0 now USB printer supported on one of my client,

Howto install Device Manager Ubuntu

Posted by Simson on February 22nd, 2009

When using Windows, you might have come across Device Manager, the handy tool that lists your PC’s hardware. Ubuntu offers a similar piece of software,but it isn’t installed by default.

After you can connect to the Internet, you can install Device Manager using the Synaptic Package Manager, as follows: 1) Select System > Administration > Synaptic Package Manager. 2) Click the Search button on the toolbar, and then type gnome-device-manager in the Search field. Click the Search button. 3) Click the program’s entry in the list of results. Select to mark it for installation (don't worry if a dialog box appears telling you additional software needs to be installed). 4) Click Apply on the toolbar.
If your computer is not yet online, you’ll need to use a computer that is online (perhaps another computer, or Windows XP if you dual-boot) to download the software, and then copy it across to your Ubuntu computer for installation. To download the software, visit the following two addresses in your browser. You will be prompted to download a file after typing each address:

http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gnome-device-manager/
gnome-device-manager_0.2-1_i386.deb
http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gnome-device-manager/
libgnome-device-manager0_0.2-1_i386.deb

After the files are downloaded, copy them to the desktop on your Ubuntu machine, using a floppy disk or maybe a USB memory stick. Then open a command-prompt window on the Ubuntu computer by clicking Applications > Accessories > Terminal. In the terminal window, type the following, hitting Enter after each line: cd ~/Desktop sudo dpkg –i libgnome-device-manager0_0.2-1_i386.deb sudo dpkg –i gnome-device-manager_0.2-1_i386.deb
After you’ve installed Device Manager, you can open it by selecting Applications > System Tools > Device Manager. You’ll need to click View > Device Properties to ensure Device Manager adds the useful Properties tab.

You should be aware of a few important differences between the Windows and Ubuntu versions of Device Manager. Though the aim of Ubuntu’s Device Manager is to manage hardware devices, the project is still in its infancy and can only provide hardware information as of the time of writing. On the other hand, Ubuntu’s list is far more comprehensive than that in Windows. In Ubuntu, Device Manager thoroughly probes the hardware to discover its capabilities.

Perhaps the biggest difference, however, is that just because a piece of hardware is listed within Ubuntu’s Device Manager, it doesn’t mean that the hardware is configured to work with Ubuntu. In fact, it doesn’t even imply that the hardware will ever work under Ubuntu. Device Manager’s list is simply the result of probing devices attached to the various system buses (PCI, AGP, USB, and so on) and reporting the data.

Nonetheless, Device Manager is the best starting place if you find that a certain piece of hardware isn’t working. If a piece of hardware is listed, then it proves, if nothing else, that the system recognizes that the hardware is attached.

syctl hardening is to help prevent spoofing and dos attacks

Posted by Simson on February 22nd, 2009

The purpose of syctl hardening is to help prevent spoofing and dos attacks. This short guide will show what I have found to be a good configuration for the sysctl.conf configuration file. The most important of the variables listed below is the enabling of syn cookie protection. Only place the bottom two if you do not want your server to respond to ICMP echo, commonly referred to as ICMP ping or just ping requests.

NOTICE: Make sure that eth0 is your primary interface, if it is not replace eth0 with eth1 in the code below. # vi /etc/sysctl.conf
Now paste the following into the file, you can overwrite the current information. #Kernel sysctl configuration file for Red Hat Linux # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details. <code> # Disables packet forwarding net.ipv4.ip_forward=0

# Disables IP source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.lo.accept_source_route = 0
net.ipv4.conf.eth0.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0

# Enable IP spoofing protection, turn on source route verification
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.lo.rp_filter = 1
net.ipv4.conf.eth0.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0

# Enable Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.lo.log_martians = 0
net.ipv4.conf.eth0.log_martians = 0

# Disables IP source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.lo.accept_source_route = 0
net.ipv4.conf.eth0.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0

# Enable IP spoofing protection, turn on source route verification
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.lo.rp_filter = 1
net.ipv4.conf.eth0.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0

# Disables the magic-sysrq key
kernel.sysrq = 0

# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15

# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1800

# Turn off the tcp_window_scaling
net.ipv4.tcp_window_scaling = 0

# Turn off the tcp_sack
net.ipv4.tcp_sack = 0

# Turn off the tcp_timestamps
net.ipv4.tcp_timestamps = 0

# Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1

# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 1

# Increases the size of the socket queue (effectively, q0).
net.ipv4.tcp_max_syn_backlog = 1024

# Increase the tcp-time-wait buckets pool size
net.ipv4.tcp_max_tw_buckets = 1440000

# Allowed local port range
net.ipv4.ip_local_port_range = 16384 65536

After you make the changes to the file you need to run # /sbin/sysctl -p
and sysctl -w net.ipv4.route.flush=1
to enable the changes without a reboot.


Copyright © 2007 Free Cookies for Linux & Windows. All rights reserved.