Membase

Membase is high performance key value pair system used for cacheing data. Membase generally provide superset of memcached.

You can use Membase to and configure either "memcached" type or "membase" type buckets. A membase-type bucket provides additional features such as key-value persistence and replication, whereas a memcached-type bucket provides only memory-only caching.

Memcached has it’s limitations. Moving to large+1 machines is going to lose a lot of your data. There is no master to organize the re-balancing of the data.We can avoid data loss using membase bucket type, while adding new server to the clusters.

Moxi

Moxi is the component of Membase that handles the re-routing of requests to other Membase servers when the server receiving the original request is not the one responsible for the data requested.

You can install membase using the instructions here.

testing membase.

you can test it using telnet utility.

shell> telnet localhost 11211 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'

set test_key 0 0 1 a STORED
or you can run a PHP script to check if membase is installed properly or not.

connect("localhost",11211); // try 127.0.0.1 instead of localhost
// if it is not working

echo "Server's version: " . $memcache->getVersion() . "
\n";

// we will create an array which will be stored in membase serialized
$testArray = array('horse', 'dog', 'pig');
$tmp = serialize($testArray);
$memcache->add("key", $tmp);
echo "Data from the cache:
\n";
print_r(unserialize($memcache->get("key")));
?>




Showing only integers for the captcha in codeigniter

I need to show 3 integer digits for my captcha in codeigniter site. I used the following for it and succeeded.

$aCaptchaCfg = array(
           'word'          => rand(111,999),   
            'img_path'   => './captcha/', 
            'img_url'       => site_url().'captcha/',
            'font_path'  => site_url().'./system/fonts/',
            'fonts'         => array('texb.ttf', 'TSCu_Comic.ttf'),
            'font_size'     => 25,     
            'img_width'  => '180', 
            'img_height' => '60',  
            'expiration' => 7200
            );

$aCaptcha = create_captcha($aCaptchaCfg);?>
Submit the word you see below
<?php
echo $aCaptcha['image'];
?>
<input type="text" name="captchafld" value="" />
     
<input type="hidden" name="Captcha" value="<?php echo $aCaptcha['word']; ?>">

Hack Facebook Accounts

If you know anything about programming websites you know the 'Forgot your password?' service has to be in direct contact with the databases in order to send requests to retrieve the forgotten information for you, basically what that means is if you 'ask' the database for the login information with the right 'code' (in our case exploit), it will send you back that information.

Facebook is one of those online companies that likes to play itself up as an invulnerable fortress of user privacy, but if you have even the slightest bit of history of using the web, you know this is hogwash, pure and simple. The fact is, just about anyone can learn how to hack someone’s Facebook or view private Facebook Profiles and do it within a few hours. There is no shortage of Facebook hacks strewn far and wide across the web, but if you are new to this game then you need to understand a very core concept to solid hacking: the easier it looks, the more risk there is going to be. You wouldn’t try to do anything else shady in a sloppy way and expect to get good results, would you? Well, learning how to hack someone’s Facebook is just like that. You are going to have to be careful if you hack Facebook password because there is a certain level of likelihood that the event will be logged by the company’s servers. If so, it may not be something they pursue you over right now, but if they ever decide to act like the music industry did towards people who downloaded MP3s, there could be unpleasant side effects. Any Facebook password hack also needs to be carefully evaluated. Know where it comes from and who is giving you the instructions before you decide to go forward.

First in the Guardian Shorts series, Phone Hacking: How the Guardian broke the story offers a definitive guide to the phone hacking scandal.
Phone hacking: how the Guardian broke the story

The ebook draws together the Guardian's unrivalled coverage, from contributors including Nick Davies, Amelia Hill, Patrick Wintour and Roy Greenslade, to present a comprehensive account of how the scandal unfolded, including past news stories, comment and analysis - from the arrest of Goodman and Mulcaire and the News of the World's claims of "one rogue reporter", to the collapse of the BSkyB bid and Rebekah Brooks and the Murdochs' select committee appearance.

Alan Rusbridger, editor-in-chief, Guardian News & Media, said: "The Guardian has doggedly pursued the phone-hacking scandal and, until recently, it had been a lonely figure reporting on it. This ebook gives readers access to our reporting and commentary on the key events that have shaped the story in a new digital format." Hack Facebook Account AT NO COST!

How do you Hack a Facebook Account, you might ask. It’s more than simple. You simply enter the url of the person’s profile you want to hack in our software, and all the questions you might have are solved right away, since you gain access to the other persons life, and be able to see what they think of you. You don’t need to hire a hacker, you don’t need any obscure computer knowledge at all. You are so lucky you got here early that you don’t even need to buy this program, because for a limited time we’re giving it for free! We’re gathering feedback via e-mail from the thousands of people that got the software, and we managed to understand what is needed: to hack facebook accounts, using a simple interface, free from details and technical terms, and smart enough to not get caught by facebook’s anti-hacking methods. It has never been easier to hack someone’s Facebook account!

A simple tool to Hack Facebook Accounts is an imminent need for many people, as said above and in the end, it is what you are probably here for; to learn how to hack a facebook account for free. So, here it is, finally, a click of your mouse away. We hope you enjoy using our Free Facebook Hack tool for whatever your need is, checking to see if your loved one is cheating you, recovering your password or you just want to hack facebook for fun. Our program is very easy to use; all you do, is enter the facebook account, and click the button. Voila, within seconds, the facebook account hacking method is complete, and you have the password. Congratulations!

Comonent/com_content/view/category/tmpl/default_item.php

here is default_item.php






params->get('filter') || $this->params->get('show_pagination_limit')) : ?>


params->get('show_headings')) : ?>




items as $item) : ?>


params->get('show_title')) : ?>
access <= $this->user->get('aid', 0)) : ?>












params->get('show_pagination')) : ?>










odd +1 ) . $this->params->get( 'pageclass_sfx' ); ?>">




title; ?>

item = $item; echo JHTML::_('icon.edit', $item, $this->params, $this->access) ?>

escape($item->title).' : ';
$link = JRoute::_('index.php?option=com_user&view=login');
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
$fullURL = new JURI($link);
$fullURL->setVar('return', base64_encode($returnURL));
$link = $fullURL->toString();
?>


params->get( 'pageclass_sfx' ); ?>" align="center">
pagination->getPagesLinks(); ?>

pagination->getPagesCounter(); ?>


category->id; ?>" type="hidden">
category->sectionid; ?>" type="hidden">
lists['task']; ?>" type="hidden">




Php Functions

PHP functions are very useful, because once coded, it can be called from anywhere within the script or from outside. Note, code block must start with function word.

Example 1 : Shows how to call function within the php Script.

<?php

function MyFirstEchoFunction()

{

echo "Hi this is the function called! <br />";

echo "And this is text created by function!";

}

MyFirstEchoFunction()

?>

Another way of calling functions is using include()..
Php Include() lets you import any php or text file in your script.

Example 2 : Create a php file somthing like "test.php" and write this code:

test.php code :
<?php

function MyFirstEchoFunction()

{

echo "Hi this is the function called! <br />";

echo "And this is text created by function!";

}

MyFirstEchoFunction()

?>

Now create destination file, something like "call.php"

Call.php code :

<?php

include("test.php"); //This is the target php file

MyFirstEchoFunction() //We just called the function coded in test.php

?>

Isn't this nice? The output of this file is :
Hi this is the function called!
And this is text created by function!

PHP Sending Emails



PHP must be configured correctly in the php.ini file with the details of how your system sends email. Open php.ini file available in /etc/ directory and find the section headed [mail function].
Windows users should ensure that two directives are supplied. The first is called SMTP that defines your email server address. The second is called sendmail_from which defines your own email address.
The configuration for Windows should look something like this:
[mail function]
; For Win32 only.
SMTP = smtp.secureserver.net

; For win32 only
sendmail_from = webmaster@tutorialspoint.com
Linux users simply need to let PHP know the location of their sendmailapplication. The path and any desired switches should be specified to the sendmail_path directive.
The configuration for Linux should look something like this:
[mail function]
; For Win32 only.
SMTP =

; For win32 only
sendmail_from =

; For Unix only
sendmail_path = /usr/sbin/sendmail -t -i
Now you are ready to go:
Sending plain text email:
PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters.
mail( to, subject, message, headers, parameters );
Here is the description for each parameter.
Parameter
Description
to
Required. Specifies the receiver / receivers of the email
subject
Required. Specifies the subject of the email. This parameter cannot contain any newline characters
message
Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters
headers
Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n)
parameters
Optional. Specifies an additional parameter to the send mail program
As soon as the mail function is called PHP will attempt to send the email then it will return true if successful or false if it is failed.
Multiple recipients can be specified as the first argument to the mail() function in a comma separated list.
Example:
Following example will send an HTML email message to xyz@somedomain.com. You can code this program in such a way that it should receive all content from the user and then it should send an email.
<html>
<head>
<title>Sending email using PHP</title>
</head>
<body>
<?php
   $to = "xyz@somedomain.com";
   $subject = "This is subject";
   $message = "This is simple text message.";
   $header = "From:abc@somedomain.com \r\n";
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true ) 
   {
      echo "Message sent successfully...";
   }
   else
   {
      echo "Message could not be sent...";
   }
?>
</body>
</html>
Sending HTML email:
When you send a text message using PHP then all the content will be treated as simple text. Even if you will include HTML tags in a text message, it will be displayed as simple text and HTML tags will not be formatted according to HTML syntax. But PHP provides option to send an HTML message as actual HTML message.
While sending an email message you can specify a Mime version, content type and character set to send an HTML email.
Example:
Following example will send an HTML email message to xyz@somedomain.com copying it to afgh@somedomain.com. You can code this program in such a way that it should recieve all content from the user and then it should send an email.
<html>
<head>
<title>Sending HTML email using PHP</title>
</head>
<body>
<?php
   $to = "xyz@somedomain.com";
   $subject = "This is subject";
   $message = "<b>This is HTML message.</b>";
   $message .= "<h1>This is headline.</h1>";
   $header = "From:abc@somedomain.com \r\n";
   $header = "Cc:afgh@somedomain.com \r\n";
   $header .= "MIME-Version: 1.0\r\n";
   $header .= "Content-type: text/html\r\n";
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true )
   {
      echo "Message sent successfully...";
   }
   else
   {
      echo "Message could not be sent...";
   }
?>
</body>
</html>
Sending attachments with email:
To send an email with mixed content requires to set Content-type header to multipart/mixed. Then text and attachment sections can be specified within boundaries.
A boundary is started with two hyphens followed by a unique number which can not appear in the message part of the email. A PHP function md5() is used to create a 32 digit hexadecimal number to create unique number. A final boundary denoting the email's final section must also end with two hyphens.
Attached files should be encoded with the base64_encode() function for safer transmission and are best split into chunks with the chunk_split()function. This adds \r\n inside the file at regular intervals, normally every 76 characters.
Following is the example which will send a file /tmp/test.txt as an attachment. you can code your program to receive an uploaded file and send it.
<html>
<head>
<title>Sending attachment using PHP</title>
</head>
<body>
<?php
  $to = "xyz@somedomain.com";
  $subject = "This is subject";
  $message = "This is test message.";
  # Open a file
  $file = fopen( "/tmp/test.txt", "r" );
  if( $file == false )
  {
     echo "Error in opening file";
     exit();
  }
  # Read the file into a variable
  $size = filesize("/tmp/test.txt");
  $content = fread( $file, $size);

  # encode the data for safe transit
  # and insert \r\n after every 76 chars.
  $encoded_content = chunk_split( base64_encode($content));
 
  # Get a random 32 bit number using time() as seed.
  $num = md5( time() );

  # Define the main headers.
  $header = "From:xyz@somedomain.com\r\n";
  $header .= "MIME-Version: 1.0\r\n";
  $header .= "Content-Type: multipart/mixed; ";
  $header .= "boundary=$num\r\n";
  $header .= "--$num\r\n";

  # Define the message section
  $header .= "Content-Type: text/plain\r\n";
  $header .= "Content-Transfer-Encoding:8bit\r\n\n";
  $header .= "$message\r\n";
  $header .= "--$num\r\n";

  # Define the attachment section
  $header .= "Content-Type:  multipart/mixed; ";
  $header .= "name=\"test.txt\"\r\n";
  $header .= "Content-Transfer-Encoding:base64\r\n";
  $header .= "Content-Disposition:attachment; ";
  $header .= "filename=\"test.txt\"\r\n\n";
  $header .= "$encoded_content\r\n";
  $header .= "--$num--";

  # Send email now
  $retval = mail ( $to, $subject, "", $header );
  if( $retval == true )
   {
      echo "Message sent successfully...";
   }
   else
   {
      echo "Message could not be sent...";
   }
?>
</body>
</html>

PHP File Download Function


Generally if we put direct links to images , .txt , .pdf in web pages they will open in browser . Sometimes we need to prompt the user with a dialog box to download and save the file ..
here is an example of such function which will download the file rather than  opening it






code :

function FileDownload($file,$DownloadName="")
{ 
  
  $DLFileName=($DownloadName==""? $file : $DownloadName);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($DLFileName));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
if(file_exists($file))
readfile($file);
exit;


}

$file is the name of the original file with the location.
$DownloadName is an optional argument which can be used to save the file with other name rather than with the name it is kept on server.

eg: FileDownload('images/uid567980.jpg','jerry.jpg')
 this will download a file uid567980.jpg from  images folder and prompt the user to download and save with a name 'jerry.jpg'


How to Use this function 


Suppose we need to download a PDF file .
We put the download link on a page like this
<a href='downloadfile.php?file=myprofile.pdf'>Click to Downlod</a>

and in downloadfile.php we use

$file=$_GET['file'];
FileDownload($file);

For extra security we can use a database to save the file location
For each file, a unique fileid (primary key)and filelocation is kept in Database table.
Pass the fileid rather than filename as arguments in the url 
In downloadfile.php we will fetch the corresponding file from the fileid using the database table
Pass the filename to function and it wil prompt the file download box.
This method is followed by major file sharing sites.