14 April 2013

How To get Resellerclub Slab 2 Pricing

I am Going To tell you how you can get resellerclub slab 2 pricing without any initial deposit.
Its hard to achieve slab 2 pricing for small hosting providers and freelancers.
If you want to get Directly slab 2 pricing for domain registration Then You can Go for http://www.india.dj
who can provide you .com / .net /.org domain registration starting from 9$ per year registration and renewal, with cheapest registrar for .in domain names. :)


We accept payments By PayPal and Ccavenue.
Domain Registration

30 March 2013

form auto save using jquery

whenever any changes occurs in the form this will make ajax request to save the form data



jQuery(document).ready(
function()
{
jQuery('#form').change(function(e)
{
var str = jQuery("#form").serialize(); //post variables present in the form input,select and all inputs
jQuery.ajax({
type: "POST", //method
url: "/save.php", //url to make request
data: str
}); //end of ajax
});// end of form change

});

1 March 2013

fetch google contacts using access_token and parse it

<?php
$access_token=$_GET['access_token'];
$max_results=$_GET['max_results'];
$api_url="https://www.google.com/m8/feeds/contacts/default/full";
$emails=array();
$content=file_get_contents("$api_url?access_token=$access_token&max-results=$max_results");

//https://www.google.com/m8/feeds/contacts/default/full?access_token=<your access token>&max-results=<maximum contacts>

$parser = xml_parser_create();
xml_parse_into_struct($parser, $content, $contacts);
xml_parser_free($parser);
foreach($contacts as $contact)
{
if($contact[tag]=="GD:EMAIL")
{
$emails[]=$contact[attributes][ADDRESS];
}
}
print_r($emails);//array of all email address
?>

17 January 2013

indian mobile number location database

Last Update on 17/Jan/2012

just an array of data which consists of operator and state name

download from here https://github.com/hebrew878/mobilenumberdb

12 December 2012

setup your own online radio station using shoutcast

requirements

1.shoutcast server (can be downloaded from http://www.shoutcast.com/broadcast-tools)

2.shoutcast transcoder(can be downloaded from http://www.shoutcast.com/broadcast-tools)

3.shoutcast license key  (its cost 5$ can be purchased  from http://shop.winamp.com/store/winamp/en_US/pd/productID.165220700)

4.one linux vps or dedicated with CentOS or Ubuntu OS 32bit prefered (cheap vps worth 6$ can be purchased from http://joesdatacenter.com)
5.small skill about linux 

installation

login to your vps/dedicated server  via ssh

download shoutcast server
# wget http://download.nullsoft.com/shoutcast/tools/sc_serv2_linux_07_31_2011.tar.gz
download shoutcast transcoder
# wget http://download.nullsoft.com/shoutcast/tools/sc_trans_linux_10_07_2011.tar.gz
extract those 2 tar balls
# tar -xvzf sc_serv2_linux_07_31_2011.tar.gz
# tar -xvzf sc_trans_linux_10_07_2011.tar.gz
# ls
now your ssh screen may look like this
now we move to confguration files sc_trans_basic.conf and sc_serv_basic.conf

sample of sc_serv_basic.conf

logfile=logs/sc_serv.log
w3clog=logs/sc_w3c.log
banfile=control/sc_serv.ban
ripfile=control/sc_serv.rip
portbase=8000
password=testing
adminpassword=changeme
streamid=1
streampath=/test.aac

sample of sc_trans_basic.conf

logfile=logs/sc_trans.log
calendarrewrite=0
encoder_1=mp3
bitrate_1=56000
outprotocol_1=3
serverip_1=127.0.0.1
serverport_1=8000
password_1=testing
streamid_1=1
endpointname_1=/Bob
streamtitle=My Test Server
streamurl=http://www.shoutcast.com
genre=Misc
playlistfile=playlists/main.lst
adminport=7999
adminuser=admin
adminpassword=goaway
unlockkeyname=YOUR LICENSE NAME THAT YOU PURCHASED
unlockkeycode=YOUR LICENSE KEY THAT YOU PURCHASED

add your mp3 files

# cd music
download any mp3 file from remotely
# wget http://blog.stephin.in/music.mp3 
you  can add any number of files to music directory
after adding some mp3 files we must have to update the playlist
# find /root/music -type f -name "*.mp3" > /root/playlists/main.lst
now go back to  main directory where shoutcast server,transcoders and config files are located
# cd /root
 

Start shoutcast server

# ./sc_serv sc_serv_basic.conf

now exit the ssh terminal

Start shoutcast transcoder

# ./sc_trans sc_trans_basic.conf

now your radio is ready open this url http://serverip:8000 from web browser

or open this url http://serverip:8000 from any media player like real player to listen the radio

How to add more files later?

just add  your desired mp3 files to music directory then update the playlist

# find /root/music -type f -name "*.mp3" > /root/playlists/main.lst
this will update the playlist

now you must have to re-start the shoutcast transcoder no need to touch shoutcast server parts

#   pkill sc_trans
# ./sc_trans sc_trans_basic.conf


:)


 

 







16 November 2012

sort multi dimentional array by the value of specific key

 

Sample Array

Array (
[0] => Array
    (
        [iid] => 1
        [invitee] => 174
        [nid] => 324343
        [showtime] => 2010-05-09 15:15:00
        [location] => 13
        [status] => 1
        [created] => 2010-05-09 15:05:00
        [updated] => 2010-05-09 16:24:00
    )
[1] => Array
    (
        [iid] => 1
        [invitee] => 220
        [nid] => 21232
        [showtime] => 2010-05-09 15:15:00
        [location] => 12
        [status] => 0
        [created] => 2010-05-10 18:11:00
        [updated] => 2010-05-10 18:11:00
    ))

 Snippet

function cmp($a, $b) {
    if ($a['status'] == $b['status']) {
        return 0;
    }
    return ($a['status'] < $b['status']) ? -1 : 1;
}

usort($array, "cmp");

Note

here array sorted by the value of specifed key(status),u can change status withany key that your array has :)

convert stdClass object array to normal array and normal array to stdClass object




stdClass obect to normal array




function objectToArray($d) {
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}

if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return array_map(__FUNCTION__, $d);
}
else {
// Return array
return $d;
}
}


normal array to stdClassobject

function arrayToObject($d) {
        if (is_array($d)) {
            /*
            * Return array converted to object
            * Using __FUNCTION__ (Magic constant)
            * for recursive call
            */
            return (object) array_map(__FUNCTION__, $d);
        }
        else {
            // Return object
            return $d;
        }
    }

Sample Output

stdClass Object
(
    [foo] => Test data
    [bar] => stdClass Object
        (
            [baaz] => Testing
            [fooz] => stdClass Object
                (
                    [baz] => Testing again
                )

        )

    [foox] => Just test
)

Array
(
    [foo] => Test data
    [bar] => Array
        (
            [baaz] => Testing
            [fooz] => Array
                (
                    [baz] => Testing again
                )

        )

    [foox] => Just test
)

  

Thanks to:

http://www.if-not-true-then-false.com/2009/php-tip-convert-stdclass-object-to-multidimensional-array-and-convert-multidimensional-array-to-stdclass-object/

 

Another simple way

json_decode(json_encode(simplexml_load_string('xml string')),1);


24 October 2012

group by,order by sum value together

Table Structure and Data

employer_id    salary

111              1000
112              2000
113              1000
111              1000
112              5000
113              2000
111              1000
113              1000


this is just an example for understanding purpose..


so here we have 3 employers,employe(111) got salary 3 times,employe(112) got salary 2times and employe(113) got salary 3 times

so we are going to sort the list by who got maximum money

SQL Query


SELECT sum( salary ) AS amt , employ_id FROM TABLE GROUP BY employer_id ORDER BY amt DESC

 
SAMPLE OUTPUT

amt     employer_id
7000   112
4000   113
3000   111
No matter howmany times the employe got salary just we are listing out based on highest earner..
















30 September 2012

way2sms php script

Last Update on 17/Jan/2013

<?php
$to=$_GET['to'];
$msg=$_GET['msg'];
$user=$_GET['user'];
$pass=$_GET['pass'];
$nos=explode(",",$to);
foreach($nos as $to)
{
$ch = curl_init("http://site5.way2sms.com/Login1.action");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, "username=$user&password=$pass&userLogin=yes&button=Login");
$response = curl_exec($ch);
curl_close($ch);
list($header, $body) = explode("\r\n\r\n", $response, 2);
$jid=explode("JSESSIONID=",$header);
$jid=explode(";",$jid[1]);
$jid=$jid[0];
$e=explode("~",$jid);
$e=$e[1];
$ch = curl_init("http://site5.way2sms.com/jsp/InstantSMS.jsp");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Cookie: JSESSIONID=$jid"));
$response = curl_exec($ch);
curl_close($ch);
$action=explode('expensive" value="',$response);
$action=explode('"',$action[1]);
$action=$action[0];
$p="embassy=$e&HiddenAction=instantsms&catnamedis=Birthday&chkall=on&expensive=$action&MobNo=$to&textArea=$msg";
$ch = curl_init("http://site5.way2sms.com/quicksms.action");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Cookie: JSESSIONID=$jid"));
curl_setopt($ch,CURLOPT_POSTFIELDS,$p);
curl_exec($ch);
curl_close($ch);
echo "<p>sms sent to $to</p>";
}
?>


download script here http://files.mspn.in/952185

singlesms usage w2s.php?user=your mobile number&pass=your password&to=destination mobile number&msg=your message ;)
multisms usage  w2s.php?user=your mobile number&pass=your password&to=mobilenumber1,mobilenumber2,mobilenumber3&msg=your message

share your feedbacks 




simple oauth with google

function code2token($code) {
    $oauth2token_url = "https://accounts.google.com/o/oauth2/token";
    $clienttoken_post = array(
    "code" => $code,
    "client_id" => '524478858957-keh6dvesm9ml3kdv67qtk8vlqori8l3r.apps.googleusercontent.com',
    "client_secret" => 'cws9DqO',
    "redirect_uri" => 'http://cc.cr/redir.php',
    "grant_type" => "authorization_code"
    );
    
    $curl = curl_init($oauth2token_url);

    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $clienttoken_post);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $json_response = curl_exec($curl);
    curl_close($curl);

    $authObj = json_decode($json_response);
    
    if (isset($authObj->refresh_token)){
        global $refreshToken;
        $refreshToken = $authObj->refresh_token;
    }
              
    $accessToken = $authObj->access_token;
    return $accessToken;
}
function call_api($accessToken,$url){
    $curl = curl_init($url);
 
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $curlheader[0] = "Authorization: Bearer " . $accessToken;
    curl_setopt($curl, CURLOPT_HTTPHEADER, $curlheader);

    $json_response = curl_exec($curl);
    curl_close($curl);
        
    $responseObj = json_decode($json_response);
    
    return $responseObj;      
}
if(isset($_REQUEST['code'])){
$data = call_api(code2token($_REQUEST['code']),"https://www.googleapis.com/oauth2/v1/userinfo");
echo print_r($data);//array of user profile details name,email,etc
}

4 July 2012

unknown file size while downloading via php script

if your browser doesn't appear to be obeying the headers generated by your PHP script—especially Content-Length—it is fairly likely that Apache's mod_deflate extension is enabled.
You can easily disable it for a single script using the following line in an applicable .htaccess file: 
 
SetEnvIfNoCase Request_URI ^/download\.php no-gzip dont-vary
 
 
 
thanks to http://paul.luminos.nl/show_post.php?p=471

7 June 2012

reset mysql root password

ps -ef | grep mysql      - checks if mysql/mysqld is one of the running processes. 
 
 
pkill mysqld             - kills the daemon, if it is running.
 
 
mysqld_safe --skip-grant-tables & - Run MySQL safe daemon with skipping grant tables
  
 
mysql -u root mysql - Login to MySQL as root with no password
 
 
UPDATE user SET password=PASSWORD("your-new-passowrd") WHERE user="root"; 
FLUSH PRIVILEGES;
 
 
 
Done 

25 March 2012

14 March 2012

[mysql ] perform order by column and rand() in single query

SELECT * FROM
(
    SELECT * FROM table1
    ORDER BY nos desc limit 0,1) 
          )  T1 ORDER BY RAND()
 
 
 
 
usage: 
if the column nos is same in multipe rows then fetch a random row..



29 February 2012

How to install the Sun Java JDK on Ubuntu 10.10?

sudo apt-get install python-software-properties

sudo add-apt-repository ppa:sun-java-community-team/sun-java6

sudo apt-get update

sudo apt-get install sun-java6-jdk

30 January 2012

search files in linux server

find /etc -name '*.conf'





/etc is directory or path


*.conf is file name * represents any name.conf files.

install Imagick on CentOS 5.x 32bit

Run the following commands


yum install ImageMagick

yum install ImageMagick-devel

yum install php-pear

pecl install imagick

echo "extension=imagick.so"> /etc/php.d/imagick.ini



service httpd restart

check Imagick is configured corectly by following command.

php -m | grep imagick

this will display output as "Imagick" that means you are Done.

cron job in kloxo/lxAdmin

command php -q /home/username/domain name/path to cron file

know the list of disabled functions on server

<?php
error_reporting(E_ALL);
$disabled_functions = ini_get('disable_functions');
if ($disabled_functions!='')
{
$arr = explode(',', $disabled_functions);
sort($arr);
echo 'Disabled Functions:
';
for ($i=0; $i<count($arr); $i++)
{
echo $i.' - '.$arr[$i].'<br>';
}
}
else
{
echo 'No functions disabled';
}
?>