What have I been doing?
I'm no security expert, but I have just implemented (read: copy and pasted code) sha256 encryption to my kcauth codeigniter plugin/module combo ( I don't like codeigniter, really don't know why...)
I'm still thinking if I will be using codeigniter's session or create my own. The former seems to be fine, but since I have no time to scrutinize the code, I cannot really rely on it. The latter would eventually be done, not at the moment since I don't have the time to create one from scratch (yet)
I have also created a HTTP GET middleware to read from a remote eventum source. Hopefully, this will scale as the middleware would be used by an application that's already a memory hog (without proper caching since it is in the development phase still, of course).
Still need to create memcache plugin for that codeigniter thingie. Also, I will need to find an easy payment gateway for the rf service that we are cooking up.
System.exit(0);
5.10.09
6.9.09
Ubuntu and AMP
Here are simple steps to get AMP (Apache, MySQL and PHP) running in Ubuntu.
1.) sudo aptitude install apache-mpm-prefork php5-mysql mysql-server -y
If you need phpmyadmin:
1.) sudo aptitude install phpmyadmin -y
2.) cd /etc/apache2/sites-available
3.) ln -s /etc/phpmyadmin/apache2.conf phpymadmin
4.) a2ensite phpymadmin
5.) /etc/init.d/apache2 reload
you can now go to : http://localhost/phpmyadmin
1.) sudo aptitude install apache-mpm-prefork php5-mysql mysql-server -y
If you need phpmyadmin:
1.) sudo aptitude install phpmyadmin -y
2.) cd /etc/apache2/sites-available
3.) ln -s /etc/phpmyadmin/apache2.conf phpymadmin
4.) a2ensite phpymadmin
5.) /etc/init.d/apache2 reload
you can now go to : http://localhost/phpmyadmin
17.8.09
Subversion + SSH on ports other than 22
What you need:
putty (not the putty.exe but the whole installer as you need pageant, plink and puttygen :D)
subversion
Step 1: Install PUTTY
Step 2: Install subversion
Step 3: Create a profile for your server (indicate port, user, etc.) using putty (be sure not to overwrite Default Profile) (i.e. profile name is MyServer)
Step 4: using puttygen, create a private key and a public key
Step 5: copy the public key ( in the puttygen window ) to the .ssh/authorized_keys (located in your home directory) on your server
Step 6: load your private key using pageant
Step 7: the url for your repository will be svn+ssh://MyServer/path/to/your/repository
You're Done!
putty (not the putty.exe but the whole installer as you need pageant, plink and puttygen :D)
subversion
Step 1: Install PUTTY
Step 2: Install subversion
Step 3: Create a profile for your server (indicate port, user, etc.) using putty (be sure not to overwrite Default Profile) (i.e. profile name is MyServer)
Step 4: using puttygen, create a private key and a public key
Step 5: copy the public key ( in the puttygen window ) to the .ssh/authorized_keys (located in your home directory) on your server
Step 6: load your private key using pageant
Step 7: the url for your repository will be svn+ssh://MyServer/path/to/your/repository
You're Done!
20.6.09
PHP5 RRD Module in Ubuntu/Debian Lenny missing!
Today, I started reading about using RRDTool in replacement for the flash-based reports that I was using for a pet project. What stunned me later was to finding out that php bindings for this nifty little tool is absent in my toolkit!
I am here now to tell you how I did it, well, sort of, :D
1.) be sure to download http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
2.) apt-get (or I use aptitude in ubuntu) install librrd-dev php5-dev
3.) extract php_rrdtool.tar.gz (tar zxvf php_rrdtool.tar.gz
4.) enter the directory created by extraction then run phpize
5.) run ./configure then make to compile the module
6.) inside the created modules directory lies two files: rrdtool.so and rrdtool.la. copy both files to your extension_dir (which you can find out if you open the php.ini that is being called by your apache web server) I saved mine in /usr/lib/php5/20060613+lfs which is the default for debian lenny
7.) add this line:
extension=rrdtool.so
in any of your php.ini file (in debian lenny's or ubuntu's case, you can create a new .ini file in /etc/php5/apache2/conf.d and put that line in there )
8.) restart your apache webserver
9.) create a phpinfo(); file and see if these lines exists:
rrdtool
rrdtool Version 1.2.x extension
rrdtool support enabled
10.) you're done!
I am here now to tell you how I did it, well, sort of, :D
1.) be sure to download http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
2.) apt-get (or I use aptitude in ubuntu) install librrd-dev php5-dev
3.) extract php_rrdtool.tar.gz (tar zxvf php_rrdtool.tar.gz
4.) enter the directory created by extraction then run phpize
5.) run ./configure then make to compile the module
6.) inside the created modules directory lies two files: rrdtool.so and rrdtool.la. copy both files to your extension_dir (which you can find out if you open the php.ini that is being called by your apache web server) I saved mine in /usr/lib/php5/20060613+lfs which is the default for debian lenny
7.) add this line:
extension=rrdtool.so
in any of your php.ini file (in debian lenny's or ubuntu's case, you can create a new .ini file in /etc/php5/apache2/conf.d and put that line in there )
8.) restart your apache webserver
9.) create a phpinfo(); file and see if these lines exists:
rrdtool
rrdtool Version 1.2.x extension
rrdtool support enabled
10.) you're done!
24.5.09
Symfony EDITOR :D
I come to realize that I can never leave without VIM. I've been hooked to it till kingdom come and I can never switch to any editor anymore. Most specially now that I have found this. Presenting (drum rolls). The VIM symfony plugin.
I would not give away the details. The thing is, I have been looking for this in almost all the editors that I have used so far. And for me, finding this thing off of the internet is a great surprise.
It does nothing more than take you to the template file of the current action that you are editing. For me this is a big thing as I don't have to leave vi just to go back and forth between the action and the template. It automatically opens it. If only komodo has this feature :D
I think that's all for now, have to get back to coding :D
http://www.vim.org/scripts/script.php?script_id=2128
Renz Out
I would not give away the details. The thing is, I have been looking for this in almost all the editors that I have used so far. And for me, finding this thing off of the internet is a great surprise.
It does nothing more than take you to the template file of the current action that you are editing. For me this is a big thing as I don't have to leave vi just to go back and forth between the action and the template. It automatically opens it. If only komodo has this feature :D
I think that's all for now, have to get back to coding :D
http://www.vim.org/scripts/script.php?script_id=2128
Renz Out
24.4.09
Upgraded to Jaunty Jackalope
Wow! I just installed Ubuntu 9.04 Jaunty Jackalope and was really amazed on how fast the thing booted up.
Also, the install experience was really really nice. I just went through 7 steps and after a restart, here I am.
Try it now. It's very stable, so far so good, considering that I already "hacked" the system compiling things that I have had in the last linux that I used.
Peace!
Also, the install experience was really really nice. I just went through 7 steps and after a restart, here I am.
Try it now. It's very stable, so far so good, considering that I already "hacked" the system compiling things that I have had in the last linux that I used.
Peace!
12.3.09
Adding gmail SMTP to symfony 1.0
PHPMailer is already included in symfony, so why add one yourself?
The thing is, I never get PHPMailer that is bundled with symfony to work with my gmail account so I decided to find something that can be done.
1.) Create a file myMailer.class.php inside your lib directory (either in apps/app_name/lib or in your root lib directory)
2.) Put these codes in there:
3.) In your controller, you can now use it this way:
$mail = myMailer(“username@gmail.com”, “thisshouldbeaveryhardpassword!@#$!@#$!@#$”, “From Me!”);
if($mail->send(“spam_victim@somewhere.com”, “This Is Spam”, “<div style=’font-size:300px’>GET THIS</div>”)) echo “Mail Sent!”;
else echo “Mail is not sent!”;
And you’re done!
The thing is, I never get PHPMailer that is bundled with symfony to work with my gmail account so I decided to find something that can be done.
1.) Create a file myMailer.class.php inside your lib directory (either in apps/app_name/lib or in your root lib directory)
2.) Put these codes in there:
class myMailer {
public function __construct($username, $password, $user_alias) {
$this->from = $username;
$this->password = $password;
$this->user_alias = $user_alias;
}
public function send($to, $subject, $body) {
$eol = "\r\n";
$host = 'gmail-smtp.l.google.com';
$port = 465; $fname = $this->user_alias;
$data = 'Date: ' . date ( 'r', time () ) . $eol;
$data .= 'From: "' . $this->from . $eol;
$data .= 'Subject: ' . $subject . $eol;
$data .= 'To: "' . $to . '" <' . $to . '>' .
$eol; $data .= 'X-Priority: 1 (High)' . $eol;
// you can comment this one out if you want a normal email.
$data .= 'X-Mailer:' . $eol;
$data .= 'MIME-Version: 1.0' . $eol;
$data .= 'Content-Type: text/plain; charset="ISO-8859-1"' . $eol;
$data .= 'Content-Transfer-Encoding: 8bit' . $eol . $eol;
$data .= $body . $eol;
$has_error = false;
if ( ( $smtp = fsockopen ( 'ssl://' . $host, $port, $errno, $errstr, 5 ) ) ) {
fputs ( $smtp, 'HELO ' . $host . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) { $
has_error = true;
}
sleep(2);
fputs ( $smtp, 'AUTH LOGIN' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, base64_encode ( $this->from ) . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, base64_encode ( $this->password ) . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, 'MAIL From: <' . $this->from . '>' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
} sleep(2);
fputs ( $smtp, 'RCPT To: <' . $to . '>' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, 'DATA' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, $data . $eol . '.' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, 'QUIT' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
fclose ( $smtp );
}
return !$has_error;
}
function test_return ( $res, &$error ) {
$out = fread ( $res, 1 );
$len = socket_get_status ( $res );
if ( $len > 0 ) {
$out .= fread ( $res, $len['unread_bytes'] );
}
//echo $out;
if ( preg_match ( "/^5/", $out ) ) {
$error = $out;
return false;
}
return true;
}
}
3.) In your controller, you can now use it this way:
$mail = myMailer(“username@gmail.com”, “thisshouldbeaveryhardpassword!@#$!@#$!@#$”, “From Me!”);
if($mail->send(“spam_victim@somewhere.com”, “This Is Spam”, “<div style=’font-size:300px’>GET THIS</div>”)) echo “Mail Sent!”;
else echo “Mail is not sent!”;
And you’re done!
8.3.09
Sending HTTP Posts through JAVA
I found this truly helpful tip :D
http://www.javaworld.com/javatips/jw-javatip34.html?page=1
From the site:
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
// URL of CGI-Bin script.
url = new URL (getCodeBase().toString() + "env.tcgi");
// URL connection channel.
urlConn = url.openConnection();
// Let the run-time system (RTS) know that we want input.
urlConn.setDoInput (true);
// Let the RTS know that we want to do output.
urlConn.setDoOutput (true);
// No caching, we want the real thing.
urlConn.setUseCaches (false);
// Specify the content type.
urlConn.setRequestProperty
("Content-Type", "application/x-www-form-urlencoded");
// Send POST output.
printout = new DataOutputStream (urlConn.getOutputStream ());
String content =
"name=" + URLEncoder.encode ("Buford Early") +
"&email=" + URLEncoder.encode ("buford@known-space.com");
printout.writeBytes (content);
printout.flush ();
printout.close ();
// Get response data.
input = new DataInputStream (urlConn.getInputStream ());
String str;
while (null != ((str = input.readLine())))
{
System.out.println (str);
textArea.appendText (str + "\n");
}
input.close ();
Thanks to the person who posted this :D
http://www.javaworld.com/javatips/jw-javatip34.html?page=1
From the site:
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
// URL of CGI-Bin script.
url = new URL (getCodeBase().toString() + "env.tcgi");
// URL connection channel.
urlConn = url.openConnection();
// Let the run-time system (RTS) know that we want input.
urlConn.setDoInput (true);
// Let the RTS know that we want to do output.
urlConn.setDoOutput (true);
// No caching, we want the real thing.
urlConn.setUseCaches (false);
// Specify the content type.
urlConn.setRequestProperty
("Content-Type", "application/x-www-form-urlencoded");
// Send POST output.
printout = new DataOutputStream (urlConn.getOutputStream ());
String content =
"name=" + URLEncoder.encode ("Buford Early") +
"&email=" + URLEncoder.encode ("buford@known-space.com");
printout.writeBytes (content);
printout.flush ();
printout.close ();
// Get response data.
input = new DataInputStream (urlConn.getInputStream ());
String str;
while (null != ((str = input.readLine())))
{
System.out.println (str);
textArea.appendText (str + "\n");
}
input.close ();
Thanks to the person who posted this :D
Subscribe to:
Posts (Atom)