jump to navigation

generate excel using php October 16, 2008

Posted by rohing in Uncategorized.
Tags:
add a comment

Piece of code for generating excel using PHP

#
header("Pragma: public");
#
header("Cache-Control: no-store, no-cache, must-revalidate");
#
header("Cache-Control: pre-check=0, post-check=0, max-age=0");
#
header("Pragma: no-cache");
#
header("Expires: 0");
#
header("Content-Transfer-Encoding: none");
#
header("Content-Type: application/vnd.ms-excel;");
#
header("Content-type: application/x-msexcel");
#
header("Content-Disposition: attachment; filename=report2_opendebitsummary".date(‘Ymd’).".xls");
#
?>
#

#

#

#

#

#

#

#

#

#

#

#

#

#

#

Employee ID Employee Name

#

#

Subversion on FreeBSD September 19, 2008

Posted by rohing in Development.
Tags:
3 comments

General Information

Subversion (SVN) is an alternative to using Concurrent Version System (CVS) for collaborative development, though it has other uses if you develop on more than one machine and wish to keep all your work in a central location.  This guide will show you how to setup Subversion with Webaccess via the Apache2 mod_dav svn module.  If you already use apache 1.3 you can continue to use that, just change the port that apache2 listens on in its httpd.conf file.

Subversion Book is an excellent resource for information outside the scope of this guide.

Requirements

  1. Local root access on the box or be able to su to root.
  2. A SSH client such as puTTy or SecureCRT (if you are setting it up remotely).
  3. A plain text editor, I prefer nano

Installation

We have to start out by building apache2.  Because we are building it with the intention of using Subversion with it, we must build it with Berkeley DB (sleepycat) support, as the Subversion filesystem is actually built as a sleepycat database.  It is this that allows for the versioning of files.

#
#
cd /usr/ports/www/apache2
make install WITH_BERKELEYDB=db42

We make sure that the apache2 aprutil library is known, this file sometimes seems to get “lost”

#
#
#
ldconfig -m /usr/local/lib/apache2/
echo “/usr/local/lib/apache2″ >> /etc/ld.so.conf
echo “/usr/local/lib/apache2″ >> /etc/ld-elf.so.conf

Instruct the Operating System to run apache2 at startup

# echo ‘apache2_enable=”YES”‘ >> /etc/rc.conf

Now to build Subversion

#
#
cd /usr/ports/devel/subversion
make install -DWITH_MOD_DAV_SVN

Configuration

OK, subversion and apache with berkeley db support are now compiled and installed.  You have a choice of either creating a single huge repository for all of your projects, or individual repositories for each.  I will detail each now.

General Setup

Create Subversion Home folder

# mkdir -p /usr/home/svn

Create a generic repository format

#
#
#
mkdir -p /usr/home/svn/default/trunk
mkdir /usr/home/svn/default/branches
mkdir /usr/home/svn/default/tags

Copy some files will need for the web interface

# cp /usr/ports/devel/subversion/work/subversion-1.0.6/tools/xslt/* /usr/local/www/data-dist/

Note: The path to the tools/xslt will change with versions of subversion so change the <em>subversion-1.0.6</em> to whatever it is for your version of subversion, ie subversion-1.0.7 or subversion-1.0.8 and so on.

Setup Blanket Access:  If you wish to enable htaccess style password login to the subversion repository then use this system. This is the basic access control system, which can be extended to enable per directory access control as well.

#
#
mkdir /usr/home/svn/access
touch /usr/home/svn/access/users

Create the users using the htpasswd utility

# htpasswd -mb /usr/home/svn/access/users <em>username</em> <em>password</em>

Configuring Apache2 for Blanket Access control

# nano -w /usr/local/etc/apache2/httpd.conf

Add the following to the httpd.conf file, this can be at the bottom or wherever, it will create a http://www.myservername.com/svn/ URL which you can then access

## SVN WebDAV Repository Setup
<Location /svn>
DAV svn
SVNParentPath /usr/home/svn/repos
SVNIndexXSLT “http://www.myservername.com/svnindex.xsl”

# anonymous first
Satisfy Any
Require valid-user

# authenticating them valid ones
AuthType Basic
AuthName “Subversion Repositories”
AuthUserFile /usr/home/svn/access/users
</Location>

This can also be placed inside a virtual host directive

Extending the Blanket Access control to enable Per-Directory Access control

# touch /usr/home/svn/access/control

If you are going to use a single large repository with all your projects in and you wish to allow and deny some users access to certain parts of the repository, then you can setup the control file like this.  In this example I will use users with the names of admin, manager (a project manager), commiter, client.  The access rules are inheritted, but I will demonstrate how to override an inheritted value.  If someone is not mentioned at all within the tree, then they are denied access.

[/]
admin = rw
manager = r

[/bigproject]
manager = rw
commiter = r

[/bigproject/trunk]
commiter = rw
client = r

[/bigproject/branches]
client = r

[/bigproject/trunk/manager_notes]
client =
commiter =

In this file from the very start the admin has full rights to the whole repository, and the manager can read and see all of the projects, but he has full access to the whole of the bigproject folder and the commiter can read the whole of the bigproject folder, all the development is to be kept in trunk so the commiter has full access to that, and the clients might want to be able to get the latest builds of a project, so they can read it.  They might also want access to the stable branches, so they are allowed read access to that.  Finally, the project manager has some project notes which he doesn’t want anyone else to gain access to, so the client and commiter are set to empty permissions which denys them access to that folder.  You can also specify general access rights for all by using the ‘*’ and assigning access rights to that.
Now the same again, but using per directory access control on a multiple repository system

[bigproject:/]
admin = rw
manager = rw
commiter = r

[bigproject:/trunk]
commiter = rw
client = r

[bigproject:/branches]
client = r

[bigproject:/trunk/manager_notes]
client =
commiter =

Edit the apache2 config file to use per-directory access control.  Find the Blanket Access control Location area and add the below lines just underneath the SVNIndexXSLT

# If we are using the Per-Directory Access Control then we leave this uncommented
# Access Control
AuthzSVNAccessFile /usr/home/svn/access/control

It should look like this

## SVN WebDAV Repository Setup
<Location /svn>
DAV svn
SVNParentPath /usr/home/svn/repos
SVNIndexXSLT “http://www.myservername.com/svnindex.xsl”

# If we are using the Per-Directory Access Control then we leave this uncommented
# Access Control
AuthzSVNAccessFile /usr/home/svn/access/control

# anonymous first
Satisfy Any
Require valid-user

# authenticating them valid ones
AuthType Basic
AuthName “Subversion Repositories”
AuthUserFile /usr/home/svn/access/users
</Location>

Building a Single General Repository

Create our single main repository

#
#
svnadmin create /usr/home/svn/repos
svn import /usr/home/svn/default file:///usr/home/svn/repos -m “initial import”

Should you later want to divide this repository into project folders, you will need to checkout the whole repository and use the svn move, svn copy and so on commands, which can be found in the Subversion Book

Building a Multiple Project Repository

Make a new repository

#
#
#
mkdir /usr/home/svn/repos
svnadmin create /usr/home/svn/repos/<em>projectname</em>
svn import /usr/home/svn/default file:///usr/home/svn/repos/<em>projectname</em> -m “Initial Import”

Final Setup

Make sure that apache can read the svn repositories

# chown -R www:www /usr/home/svn

and make the access control and userlist readable only by apache.  All the contents are pretty much encrypted, but you don’t want other shell users peeking at them, though they could get through via a php script, but this is the best way to go about it.

#
#
chmod 600 /usr/home/svn/access/control
chmod 600 /usr/home/svn/access/users

There, you now have a fully working Subversion Repository.  To checkout the contents of the trunk of a project in your repository via the command line tool

# svn checkout http://www.mydomain.com/svn/<em>projectname</em>/trunk <em>projectname</em>

this will make a folder called “projectname” in the current folder you are in when you run the command.

Once you have made changes to a project you can commit those changes by changing into the project folder then

# svn commit -m “Notes regarding the changes”

And finally to update your copy of the code from the repository, change into the project folder then

# svn update

These commands are all for the SVN Command line tool, which is installed as part of the devel/subversion port.  If you wish to use the command line tool and not create the files needed for running a repository with apache2, then use

#
#
cd /usr/ports/devel/subversion
make install clean

and skip the remaining steps.

There is also a range of clients.  The best for Windows, in my opinion, is TortoiseSVN, a comprehensive list of other clients for SVN can be found here

subversion on windows September 17, 2008

Posted by rohing in Uncategorized.
Tags:
1 comment so far

I came across this google search, but the page seemed to be deleted or moved away, so here is the original article on how to configure SVN using windows….the credit goes to the original author and not to me…I have just blogged it for reference purposes…

Setting up a Subversion Server under Windows

I talked a little bit about what Subversion is in my previous post. Now, let’s get it set it up in Windows.

Luckily for us, Joe White has done most of the work already; he has a tremendously helpful post that documents how to set up Subversion. I’ll see if I can streamline his excellent post a bit further, and illustrate it with screenshots.

A) Download Subversion

You’ll need the latest version of..

B) Install Subversion

  1. Unzip the Windows binaries to a folder of your choice. I chose c:\program files\subversion\ as my path.
  2. Now, add the subversion binaries to the path environment variable for the machine. I used %programfiles%\subversion\bin\
  3. You’ll also need another environment variable, SVN_EDITOR, set to the text editor of your choice. I used c:\windows\notepad.exe

C) Create a Repository

  1. Open a command prompt and type
    svnadmin create "c:\Documents and Settings\Subversion Repository"
  2. Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file:
    [general]
    anon-access = read
    auth-access = write
    password-db = passwd

    Next, uncomment these lines in the /conf/passwd file:

    [users]
    harry = harryssecret
    sally = sallyssecret

D) Verify that everything is working

  1. Start the subversion server by issuing this command in the command window:
    svnserve --daemon --root "C:\Documents and Settings\Subversion Repository"
  2. Create a project by opening a second command window and entering this command:
    svn mkdir svn://localhost/myproject

    It’s a standard Subversion convention to have three folders at the root of a project:

    /trunk
    /branches
    /tags

  3. At this point, Notepad should launch:Enter any comment you want at the top of the file, then save and exit.
  4. You’ll now be prompted for credentials. In my case I was prompted for the administrator credentials as well:
    Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Password for 'Administrator': *********
    Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Username: sally
    Password for 'sally': ************
    
    Committed revision 1.

    Congratulations! You just checked a change into Subversion!

E) Start the server as a service

  1. Stop the existing command window that’s running svnserve by pressing CTRL+C.
  2. Copy the file SVNService.exe from the zip file of the same name to the subversion\bin folder.
  3. Install the service by issuing the following commands:
    svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"
    sc config svnservice start= auto
    net start svnservice
  4. Test the new service by listing all the files in the repository:
    svn ls svn://localhost/

    You should see the single project we created earlier, myproject/

F) Set up the shell extension

  1. Run the TortoiseSVN installer. It will tell you to restart, but you don’t need to.
  2. Create a project folder somewhere on your hard drive. Right click in that folder and select “SVN Checkout…”type svn://localhost/myproject/ for the repository URL and click OK.

  3. Create a new file in that directory. Right click the file and select “TortoiseSVN, Add”
  4. The file hasn’t actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select “SVN Commit”:

And we’re done! You now have a networked Subversion server and client set up on your machine. Note that the default port for svnserve is 3690.

installing and configuring mysql on freebsd September 17, 2008

Posted by rohing in mysql.
Tags:
1 comment so far

i just finished my mysql installation. Here the steps :

cd /usr/ports/databases/mysql41-server/
make install clean
/usr/local/bin/mysql_install_db
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
/usr/local/bin/mysqld_safe –user=mysql &
/usr/local/bin/mysqladmin -u root password newpassword
echo ‘mysql_enable=”YES”‘>> /etc/rc.conf

That’s all the steps for installing and configuring mysql in freebsd..so easy is it?

my new blog world September 17, 2008

Posted by rohing in Uncategorized.
add a comment

i registered my new blog…@wordpress..

Hello world! March 23, 2006

Posted by rohing in Uncategorized.
1 comment so far

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!