Thursday, 29 March 2012

My Notes

My notes.

Quran Sura Yasin

Quran Sura Yasin, sura 36

Search or sort Apache logs

Search or sort Apache logs

Script to count unique ips in apache access log


cat my-web-app-access_log.4 | grep "04/Mar/2012:10:" >> day_04.txt

awk '{!a[$1]++}END{for(i in a) if ( a[i] >10 ) print a[i],i }' myfile.txt | sort -nr | more

awk '{!a[$1]++}END{for(i in a) if ( a[i] >10 ) print a[i],i }' myfile.txt

Wednesday, 29 February 2012

Flashback

At last we have the lience to use Flashback:

Good site.
http://www.oracle-developer.net/display.php?id=313


SQL> FLASHBACK TABLE t TO BEFORE DROP;

Tuesday, 24 January 2012

Php time out sample code



session_start();

// In seconds, so 900 is 15min
$inactive = 900;

if(isset($_SESSION['start']) ) {

$session_life = time() - $_SESSION['start'];

if($session_life > $inactive){

header("Location: user_logout.php");

}

}

$_SESSION['start'] = time();

Friday, 20 January 2012

MySql admin Create user / root privs

MySql admin commands

Option 1 - New user, Dedicated commands
========

CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1';

GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'user1'@'localhost';



Option 2 - New user, Direct sql
========

INSERT INTO user (Host,User,Password,Select_priv,Insert_priv)
VALUES('%','user4',PASSWORD('pass3'),'Y','Y');



Root privs

GRANT ALL PRIVILEGES ON *.* TO 'user1'@'%'
GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost'
FLUSH PRIVILEGES;



Ref: http://www.databasef1.com/tutorial/mysql-create-user.html

Sunday, 4 December 2011

Ubuntu secure

http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/

My Install:

apt-get install ssh
apt-get install apache2
apt-get install php5 libapache2-mod-php5
apt-get install php5-mysql
apt-get install denyhosts


Try to get desktop via vnc

apt-get install vnc4server
apt-get install ubuntu-desktop
apt-get install gnome-tweak-tool
apt-get install gnome-shell



To allow SSL on Apache

a2enmod ssl
a2ensite default-ssl
/etc/init.d/apache2 stop
/etc/init.d/apache2 start

good site: https://help.ubuntu.com/10.04/serverguide/C/httpd.html


To remove Apache Signature and custom 404


# vi /etc/apache2/apache2.conf add at the bottom

ServerTokens Prod
ServerSignature Off
ErrorDocument 404 /err.html
ErrorDocument 403 /err.html



Disable docroot / folder display, remove Indexes from Options like below

# vi sites-available/default-ssl and remove Indexes

[Directory /var/www/]
#Options Indexes FollowSymLinks MultiViews
Options FollowSymLinks MultiView
AllowOverride None
Order allow,deny
allow from all
[/Directory]