Latest Entries »

Remove malware attack from website

To protect your website from malware attack I per form follow a few steps and get protect website from further attack.

Clean your files or upload clean files and use following line in your.htaccess file for further prevention of iframe /javascript injection.

RewriteEngine on
RewriteCond %{QUERY_STRING} ^.*(;|<|>|’|”|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|cast|set|declare|drop|update|md5|benchmark).* [NC]
RewriteRule .* – [F]

This code is generally uploaded through FTP from infected PC, please scan your PC and change your FTP / control panel password asap.

Feel free to post comment for any query..

Jquery nested drag and drop widget

Tutorial for Jquery nested drag and drop widget

Step 1. Include the following js files in your head section

<script src=”./jquery-1.4.4.js”></script>
<script src=”./jquery.ui.core.js”></script>
<script src=”./jquery.ui.widget.js”></script>
<script src=”./jquery.ui.mouse.js”></script>
<script src=”./jquery.ui.sortable.js”></script>
<script src=”./jquery.ui.draggable.js”></script>

Step 2. Put the below css in you css file of style tag

<style type=”text/css”>
h1
{
color:red;
background: gray;
}
dl dl{
margin:20px;
}
dl,ul,li,dt
{
border-width: 2px;
border-style: dashed;
border-color: #D3D3D3;
display:block;
padding:20px;
margin-top:10px;
}
.ui-state-disabled
{
padding : 0px !important;
background: gray;
}
dl#thirdlidivul1  dt
{
width:100px;
}
dl#thirdlidivul2  dt
{
width:100px;
}
#thirdlidiv  dl
{

width:150px;
margin:10px;
}
#thirdlidiv
{
border-width: 2px;
border-style: dashed;
border-color: #D3D3D3;
}
#maindiv
{
border-width: 2px;
border-style: dashed;
border-color: #D3D3D3;
width: 650px;
padding:20px;
float:left;
}
.sidebar{ width:288px; float:left; margin:0px 0px 0px 10px}
.sidebar ul{ margin-top:0px; }
.ui-state-highlight { height: 10em; line-height: 1.2em; background-color:yellow;}
.ui-state-highlight1 { height: 1em; line-height: 1.2em; background-color:yellow;}
.ui-state-highlight2 { height: 2em; line-height: 1.2em; background-color:yellow;}
.clear
{
clear:both;
line-height:0px;
height:0px;
}
</style>

3. Put the below html in you body section

<h1>Main Div</h1>
<div id=”maindiv”>
<h1>Mail UL</h1>
<ul id=”mainul”>
<li><h1>Un movable (&lt;li&gt;)</h1></li>
<li>
<h1>First LI</h1><p>All callbacks (start, stop, drag) receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument ‘ui’):</p>
</li>
<li>
<h1>Second LI</h1><p>All callbacks (start, stop, drag) receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument ‘ui’):</p>
</li>
<li>
<h1>Third LI</h1><p>All callbacks (start, stop, drag) receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument ‘ui’):</p>
<div id=”thirdlidiv” style=”padding:20px; margin:0px auto; width:480px”>
<dl id=”thirdlidivul1″ style=”float: left;”>
<dt>Li 1</dt>
<dt>Li 2</dt>
<dt>Li 3</dt>
<dt>Li 4</dt>
</dl>

<dl id=”thirdlidivul2″ style=”float: left;”>
<dt>Li 1</dt>
<dt>Li 2</dt>
<dt>Li 3</dt>
<dt>Li 4</dt>
</dl>
<div></div>
</div>
<div></div>
</li>
<li>
<h1>Fourth LI</h1><p>All callbacks (start, stop, drag) receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument ‘ui’):</p>
<div id=”forthlidiv”>
<dl id=”forthlidivul”>
<dt>Li 1</dt>
<dt>Li 2</dt>
<dt>Li 3</dt>
<dt>Li 4</dt>
</dl>
</div>
</li>
</ul>
</div>
<div>
<ul id=”sidebarul”>
<li>Li 1</li>
<li>Li 2</li>
<li>Li 3</li>
</ul>
</div>

Last Step . put the below js code in your html file just before the body tag end.

<script type=”text/javascript”>
$(document).ready(function()    {
$(‘ul#mainul’).sortable({
connectWith: “div > ul li.drli”,
placeholder: “ui-state-highlight”,
items: “li:not(.ui-state-disabled)”,
containment:’parent’,
handle : “h1″
});

$(‘dl#forthlidivul’).sortable({
connectWith: “dt”,
placeholder: “ui-state-highlight1″,
containment:’parent’,
});

$(‘dl#thirdlidivul1, dl#thirdlidivul2′).sortable({
connectWith: “div#thirdlidiv  dl”,
placeholder: “ui-state-highlight1″,
containment:’div#thirdlidiv’,
});

$(‘ul#sidebarul’).sortable({
connectWith: “div#sidebar > ul”,
placeholder: “ui-state-highlight2″,
containment:’parent’,
});
});

</script>

You can also check our online demo

To download please click here

SFTP PHP file handling class

PHP class for SFTP Connection and file operation, set email on various steps to debug

class SFTPConnection
{
private $connection;
private $sftp;

var $headers  = “MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nTo: Tarun <name@mydomain.com>\r\nFrom: <admin@mydomain.com>\r\n”;

public function __construct ($host, $port=22)
{
$message = “Connectivity started”;
$subject = “This is to confirm that the connectivity started but not done”;
//mail ($this->to, $subject, $message, $this->headers);

$this->connection = ssh2_connect ($host, $port);
if (! $this->connection)
{
$message = “Connectivity done”;
$subject = “Could not connect to $host on port $port.”;

//mail ($this->to, $subject, $message, $this->headers);

throw new Exception (“Could not connect to $host on port $port.”);
}
else
{
$message = “Connectivity Success”;
$subject = “success connect to $host on port $port.”;
mail ($this->to, $subject, $message, $this->headers);
}

//mail($this->to, “test”, “Test “, $this->headers);

}

public function login ($username, $password)
{
if (! @ssh2_auth_password ($this->connection, $username, $password))
{
$message = “Could not authenticate with username $username ” .
“and password $password.”;
$subject = “connection error”;
//mail ($this->to, $subject, $message, $this->headers);

throw new Exception (“Could not authenticate with username $username ” .
“and password $password.”);
}

$this->sftp = @ssh2_sftp ($this->connection);
if (! $this->sftp)
{
$message = “Could not initialize SFTP subsystem.”;
$subject = “initialization error”;
//mail ($this->to, $subject, $message, $this->headers);
throw new Exception(“Could not initialize SFTP subsystem.”);
}

}

public function createFile ($newfilepath)
{
$sftp = $this->sftp;
@ssh2_sftp_mkdir ($sftp, $newfilepath);
}

public function uploadFile ($local_file, $remote_file)
{
$sftp = $this->sftp;
$stream = fopen (“ssh2.sftp://$sftp$remote_file”, ‘w+’);

if  (! $stream)
{
$message = “Could not open file: $remote_file”;
$subject = “error1″;
//mail ($this->to, $subject, $message, $this->headers);
throw new Exception (“Could not open file: $remote_file”);
}

$data_to_send = @file_get_contents ($local_file);

if  ($data_to_send === false)
{
$message = “Could not open local file: $local_file”;
$subject = “error2″;
//mail ($this->to, $subject, $message, $this->headers);
throw new Exception (“Could not open local file: $local_file.”);
}

if  (@fwrite ($stream, $data_to_send) === false)
{
$message = “Could not send data from file: $local_file”;
$subject = “error3″;
mail ($this->to, $subject, $message, $this->headers);
throw new Exception (“Could not send data from file: $local_file.”);
}
else
{
$message = “File transferd success”;
$subject = “correct”;
//mail ($this->to, $subject, $message, $this->headers);

$success = TRUE;
}
@fclose ($stream);
return $success;
}
}

Checkout various functions…

Use Bake for Cake PHP

The most basic functions class you can develop with bake if you are using cakePHP framework.

First do following in your PHP for Cake :

  • Change the config file of php/php.ini : register_globals = On
  • Enable mod rewrite in apache/conf/httpd.conf : remove # from begining,
    LoadModule rewrite_module modules/mod_rewrite.so

Following easy steps to get the bake “myproject” is name :

  • Define database configuration in myproject/app/config/

in dateabase.php (that you get on new downloaded files)

  • Then set the system path variable:

;c:\xampp\php;c:\xampp\htdocs\myproject\cake\console\

you can find it

- My Computer [properties]
– Advanced
— Environment Variables
—- System Variables

Find for Path and append above path as per your folder.

Now run on command prompt

cd c:\xampp\htdocs\myproject\
c:\xampp\htdocs\myproject\>cake\console\cake bake

It simply run the bake file and menu ridden program comes you can make model, view and controller by  following the simple questions.

Hope this help you out..

How to use .HTACCESS

Hi frnd’s during a regular project I setup .htaccess file with the following code for general rewrite with name :

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^mylink/(.*)$ myfile.php?request_variable_name=$1

RewriteRule ^(.*)/mylink2/(.*).html$ mylinkfile2.php?request_variable_name1=$1&static_request_variable_name=value&request_variable_name2=$2 [NC]

———————————————–

So in the above ex. I try to rewrite mylink – seo url with the slug (the request variable) to take there values in myfile.php with the request variable names the only trick is $1, $2 that to be taken as value.

Swap two variables without using third variable

$a=10;
$b=20;
print (“a=$a, b=$b <br>”);
$a=$a^$b;
$b=$a^$b;
$a=$a^$b;

print (“a=$a, b=$b <br>”);

Cron Job setting for Linux

*                 *                   *                 *                   *                                 /usr/local/bin/php /home/domainname/public_html/filename

min          hour            Day    of    month         Day of Week

Video player for website

Hi, once a site I have to play video. For that I use .flv file which can be play with flash player.

The basic code is as follow :

<script src=”http://www.google.com/jsapi” language=”javascript” type=”text/javascript”></script>

<script language=”javascript” type=”text/javascript” >
google.load(“jquery”, “1.4.2″);
google.load(“swfobject”, “2.2″);
</script>

<style type=”text/css”>
/*Video page*/
.video-container,
.banner-container{
margin:0 0 15px 0;
}
</style>
<div id=”flvplayer”>
You need the latest version of Adobe Flash Player to view this video. <a href=”http://www.adobe.com/go/getflashplayer”>Click here to download.</a><br>

You see this message either because your Flash Player is outdated or because you disabled JavaScript in your browser.
<script type=”text/javascript”>
var flashvars = {};
flashvars.autoplay = “false”;
flashvars.autoreplay = “false”;
flashvars.video_url = ‘http://localhost/swfplayer/files/4b66c8e65bcbd.flv’;
flashvars.postroll_url = ‘http://localhost/swfplayer/swf/related.swf’;
flashvars.options = ‘http://localhost/swfplayer’;
flashvars.related_url = ‘http://localhost/swfplayer/67185/182770/’;
flashvars.image_url = ‘http://localhost/swfplayer/images/1.jpg’;
flashvars.link_url = ‘http://localhost/swfplayer/67185/’;
flashvars.video_title = ‘Young+girls’;
var params = {};
params.allowfullscreen = “true”;
params.allowScriptAccess = “always”;
params.wmode = “transparent”;

swfobject.embedSWF(‘http://localhost/swfplayer/swf/player.swf’, “flvplayer”, “608″, “481″, ’9.0.0′, ‘http://localhost/swfplayer/swf/expressInstall.swf’, flashvars, params, {});
</script>
</div>
</div>

You need the latest version of Adobe Flash Player to view this video. Click here to download.
You see this message either because your Flash Player is outdated or because you disabled JavaScript in your browser.

You must have to download the related files and folder click here.

Hi friends, below is the code to call a function on page load in 2 seconds :

<html>
<title>onload Popup</title>
<script type=”text/javascript”>
setTimeout(“myPopup()”,2000);
function myPopup()
{
window.open (“http://www.google.com”, “mywindow”,”location=1,status=1,scrollbars=1, width=300,height=400″);
}
</script>

<body>
<H1>How to call a javascript function automatically </H1>
</body>
</html>

To change the function name and time modify in the ‘setTimeout’ function.

In the above function calling google page in popup window, you may set your own page.

Excel parsing using PHP

Hi all, I go through a regular search to parse excell file using PHP and finally I get the solution.

For this we need – excel foder, contains – oleread.inc and reader.php files.

<?

if(is_uploaded_file($_FILES['data']['tmp_name']))

{
$file_type_arr=explode(“.”,$_FILES['data']['name']);
if($file_type_arr[1]==”xls”)

{
ini_set(‘session.gc_maxlifetime’,86400);
require_once ‘Excel/reader.php’;

// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();

// Set output Encoding.
$data->setOutputEncoding(‘CP1251′);

$data->read($_FILES['data']['tmp_name']);

//Do the rest work with excell data

}

}

?>

Download – reader.php the parsing file.

Powered by WordPress. Theme: Motion by 85ideas.