Archive

Author Archive

Use Jquery with Smarty Template Engine

August 31st, 2010 emran No comments

Smarty is the template engine which is fast and nicely design for php programmers. Smarty makes your PHP code cleaner and promotes the V in MVC.

Jquery is the another lightweight JavaScript Library for rapid web development.

Anyway, do you see the problem that might arise when you try to embed your jQuery code or any other javascript library (like Prototype, MooTools, Extjs, etc.) that uses $ as a function name in the ?

The solution:
Use Smarty’s {literal}…{/literal} directives to tell Smarty parsing engine that it should not interpret the code within the block. Smarty will not parse the code which is inside of literal block.

Example:

User
<script type=”text/javascript”>// <![CDATA[
{literal}
$(document).ready(function(){
$(".clazz").css("color", "red");
});
{/literal}
// ]]></script>

User Information:

Name: {$name}

Categories: Jquery, PHP Tags:

How to disable SELinux in CentOS?

June 16th, 2010 emran No comments

In Fedora Core and RedHat Enterprise or CentOS, edit /etc/selinux/config and change the SELINUX line to SELINUX=disabled

That’s all.

Block DDoS attack on SIP Server

June 16th, 2010 emran No comments

Sometimes SIP Server attacked by hacker with huge number of SIP Registration.Which make mad the SIP Server.Full service can be get down. It can be blocked easily by IPTables. IPTables will work as Session Border Controller(SBC) for SIP Server. This script will work only with SIP.it will not work for TLS or SIPS.

#!/bin/sh
#
# INVITE rate, per host. Remember a successful (authenticated) call requires 2 INVITEs-
# Initial INVITE, 407 auth required (w/ nonce), INVITE with nonce and authentication.
IRATE=4/minute

# REGISTER rate, per host.
RRATE=2/minute

# All other SIP methods rate, per host. Be careful with SUBSCRIBEs, OPTIONS, CANCELs, etc.
ORATE=10/minute

# Methods for this script to ignore. These SIP methods are always allowed.
IGMETH=”OPTIONS”

# Burst
BURST=1

# Interface(s) to protect on INPUT. Seperate multiple interfaces with spaces.
# This will protect SIP services on THIS HOST.
IFACE=”eth0″

# Reject/drop action – usually something like DROP or REJECT.
# Use ACCEPT to use this script to not filter traffic but still collect statistics.
DACTION=DROP

# Protocol(s) to filter – can be either tcp or udp or both. Seperate multiples with spaces.
PROTOCOLS=”udp tcp”

# Enable logging.
#LOG=YES

# Block tel: URIs completely?
# P.S. – tel: sucks!
BLOCKTEL=yes

# Interface(s) to protect on FORWARD. Seperate multiple interfaces with spaces.
# The same hashtable will protect the entire network from the same host(s).
# Destination IP is NOT taken into consideration.
# This will protect any SIP services running on the network that uses this machine
# as a router (as long as you get the interfaces right).
#FIFACE=”eth0″

# Location of iptables binary.
IPTABLES=`which iptables`

# Search packet to this location. A larger offset looks further into the packet
# and takes more time but could catch more attacks (and false alarms).
# Remember, the method to match on is always in the beginning of the packet.
OFFSET=65

# SIP port
SPORT=5060

if [ ! "$1" ]
then
echo “SIP DoS/DDoS mitigation script for iptables
See top of script for configuration

Usage:
$0 [start|stop|status]”
exit 1
fi

if [ "$1" = "status" ]
then
$IPTABLES -L -v -n
exit
fi

# Setup iptables
$IPTABLES -F sipdos 2> /dev/null
$IPTABLES -X sipdos 2> /dev/null
$IPTABLES -N sipdos 2> /dev/null

if [ "$1" = "stop" ]
then
echo “Clearing iptables rules…”
if [ "$FIFACE" ]
then
$IPTABLES -F FORWARD 2> /dev/null
fi
$IPTABLES -F INPUT 2> /dev/null
exit
fi

# Send the right traffic through our chain
for i in $IFACE
do
for l in $PROTOCOLS
do
$IPTABLES -A INPUT -i $i -m $l -p $l –dport $SPORT -j sipdos
done
done

# Send the right forwarded traffic through our chain
if [ "$FIFACE" ]
then
for j in $FIFACE
do
for l in $PROTOCOLS
do
$IPTABLES -A FORWARD -i $j -m $l -p $l –dport $SPORT -j sipdos
done
done
fi

# “Handle” tel: URIs
if [ "$BLOCKTEL" ]
then
$IPTABLES -A sipdos -m string –string “tel:” –algo bm –to $OFFSET -j $DACTION
fi

# Ignore certain (configured) methods
if [ "$IGMETH" ]
then
for k in $IGMETH
do
$IPTABLES -A sipdos -m string –string “$k sip:” –algo bm –to $OFFSET -j ACCEPT
done
fi

# Finally set some limits…

# INVITE limit
$IPTABLES -A sipdos -m string –string “INVITE sip:” –algo bm –to $OFFSET \
-m hashlimit –hashlimit $IRATE –hashlimit-burst $BURST \
–hashlimit-mode srcip,dstport –hashlimit-name sip_i_limit -j ACCEPT

# REGISTER limit
$IPTABLES -A sipdos -m string –string “REGISTER sip:” –algo bm –to $OFFSET \
-m hashlimit –hashlimit $RRATE –hashlimit-burst $BURST \
–hashlimit-mode srcip,dstport –hashlimit-name sip_r_limit -j ACCEPT

# All other SIP packets…
$IPTABLES -A sipdos -m hashlimit –hashlimit $ORATE –hashlimit-burst $BURST \
–hashlimit-mode srcip,dstport –hashlimit-name sip_o_limit -j ACCEPT

# Take action on everything else
if [ $LOG ]
then
$IPTABLES -A sipdos -j LOG
fi

$IPTABLES -A sipdos -j $DACTION

Freebsd: Install wget Utility To Download Files From The Internet

June 7th, 2010 emran No comments

Install wget Using FreeBSD Ports Collection

Type the following command as root user to upgrade ports tree, enter:

# portsnap fetch update

Now, install the wget, enter:

# cd /usr/ports/ftp/wget
# make install clean
# rehash

Categories: FreeBSD, Unix Tags:

Git Tutorial

June 7th, 2010 emran No comments

You have to download your project and place to a folder.

$ tar xzf project.tar.gz
$ cd project
$ git init-db

This will initialize your project on git.now you have to add files which will monitored via git.

$ git add .

these means git will monitor all files.

$ git commit -a

This will prompt a message to commit.
Try modifying some files, then run

$git diff

to review your changes.

Categories: CentOS, Linux Tags:

OpenSIPS Externel Perl Script Run

June 7th, 2010 emran No comments

You can easily redirect any sip uri based on opensips exec.so module on perl script. you need to load

loadmodule “exec.so”

In the route section you have to exec perl script with paramter $tu (To username) and $fu (from Username).

route {

if(method == “INVITE”) {
exec_dset(“/usr/local/bin/route.pl $fU $tU”);
sl_send_reply(“302″,”LCR Redirect”);
} else {
route(1);
}

}

In the perl script just write the follow code:

#!/bin/sh
echo sip:+121242415112@howtonix.com

NOTE: To get this to work correctly with Asterisk you need to add “promiscredir=yes” to the general section of your sip.conf

VoIP on Symbian Mobile

June 7th, 2010 emran No comments

Now a days it is very hot topics about voip on symbian mobile. To Call Over the internet from Mobile phone helps peoples life easier.There are few commercial and free voip mobile dialer for symbian and android.

One of them is Fring.You can make voip sip calls from fring.You can also use MSN, yahoo and Google.It supports many devices such as Nokia N73,n71,n75,E65 etc. It also support Other platform like iphone. It supports g711,GSM codec only.

SIPDialer is a product of E-SOFT BILLING PTE LTD. They provide commercial service. Their SIPDialer supports Symbian s60 3rd ed and android phone. You can send a demo request  from their website www.e-softbilling.com. They provide 5 days demo to run own sip proxy. SIPDialer supports G729,AMR,GSM and g711 codec. SIPDialre has balance display, realtime call duration, incoming call, DTMF, phone book features.Proxy IP can be changed on the fly.

SIPDroid is another opensource application for android phone.you can make audio and video calls from SIPDroid.It is based on mjsip.It has gsm, g711,ilbc and speex codecs.

Reducing the size of your GCCE executables for Symbian Carbide C++

June 7th, 2010 emran No comments

Add the following code in mmp file:
OPTION GCCE -O2 -fno-unit-at-a-time

H323Plus on FreeSWITCH

March 10th, 2010 emran No comments

First you have to download & install ptlib:

In your home, create a directory e.g. h323
mkdir -p ~/h323
cd ~/h323
wget http://www.h323plus.org/source/download/ptlib-2.4.5.tar.bz2
bunzip2 ptlib-2.4.5.tar.bz2
tar -xvf ptlib-2.4.5.tar.bz2
mv ptlib-2.4.5 ptlib-trunk
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/local/lib
cd ptlib-trunk
./configure
make
sudo make install
cd ..

Now, install h323plus

cd ~/h323

http://www.h323plus.org/source/download/h323plus-v1_21_0.tar.gz

export PTLIBDIR=~/h323/ptlib-trunk

tar -xzvf h323plus-v1_21_0.tar.gz
cd h323plus
./configure
make
make install

Now install mod_h323 on Freeswitch.

assuming you have FS source in your home
cd ~/freeswitch-trunk

make mod_h323-clean
make mod_h323
sudo make mod_h323-install

Now configure h323.conf.xml. It is similiar like mod_opal.

<configuration name=”h323.conf” description=”H323 Endpoints”>
  <settings>
    <param name=”trace-level” value=”4″/>
    <param name=”context” value=”public”/>
    <param name=”dialplan” value=”XML”/>
    <param name=”codec-prefs” value=”PCMU,PCMU,G729,GSM”/>
  </settings>
  <listeners>
    <listener name=”myH323_listener”>
      <param name=”h323-ip” value=”$${local_ip_v4}”/>
      <param name=”h323-port” value=”1720″/>
    </listener>
  </listeners>
</configuration>

 

   

How to create tar.gz?

December 19th, 2009 emran No comments

You can create tar.gz file with the following command.DO NOT ENTER / after the directory name.

tar -cvzf  test.tar.gz test

7 visitors online right now
7 guests, 0 members
Max visitors today: 7 at 11:34 pm UTC
This month: 7 at 09-03-2010 11:34 pm UTC
This year: 43 at 06-10-2010 04:02 pm UTC
All time: 43 at 06-10-2010 04:02 pm UTC