Installing PEAR 1.1.6 in a Hosting Environment

Contrary to the instructions provided on the official PHP website, there are a few extra steps that you need to make in order to setup PEAR on your hosting provider’s systems if they don’t have it installed already.  First, you’ll need to download the go-pear.php file and then make the following changes to lines 116-119 of the code:

From:

'PEAR5.php' => 'https://raw.github.com/pear/pear-core/master/PEAR5.php',
'PEAR.php' => 'https://raw.github.com/pear/pear-core/master/PEAR.php',
'Archive/Tar.php' => 'https://raw.github.com/pear/Archive_Tar/master/Archive/Tar.php',
'Console/Getopt.php' => 'https://raw.github.com/pear/Console_Getopt/trunk/Console/Getopt.php',

To:

'PEAR5.php' => 'https://raw.githubusercontent.com/pear/pear-core/master/PEAR5.php',
'PEAR.php' => 'https://raw.githubusercontent.com/pear/pear-core/master/PEAR.php',
'Archive/Tar.php' => 'https://raw.githubusercontent.com/pear/Archive_Tar/master/Archive/Tar.php',
'Console/Getopt.php' => 'https://raw.githubusercontent.com/pear/Console_Getopt/master/Console/Getopt.php',

Basically, you need to change github to githubusercontent on all 4 lines and on the fourth line, change trunk to master.  Upload the go-pear.php file to your hosting account and in a browser, execute it by typing in the URL (e.g. http://www.mydomainname.com/go-pear.php).  You should get a screen like the one below.

go-pear-installer

You can safely ignore the ereg() function deprecation error if you get it.  Click on the Next >> link.

configuration

The Installation prefix should be an absolute path to the directory where go-pear.php was uploaded.  You also might need to change line 11 and ask your hosting provider what value to enter because for me, it was not pointing to the correct directory where PHP was installed.  It was pointing to my hosting space which is on another drive.  You can leave the other values at their default settings or modify them accordingly to your needs.  Click on the Install button when you’re ready to begin.

installation

You’ll get an Installation in progress screen, and all you can do is grab a cup of your favorite drink while you wait.  It does take a few minutes.

completed

After waiting a bit, you should get an installation completed screen like the one above.  Pay attention to the Note as you will need to add that to your include_path in either the php.ini or .user.ini file so that your code can find the PEAR files.  If you click on the Start Web Frontend of the PEAR Installer >> link, it probably won’t work.  There is one more step to be performed in order to get PEAR (or at least the management console) working correctly.  There should be a pear.conf file in the directory where you uploaded go-pear.php.  Make a copy of that file and name it pear.ini, or you can just rename it.  I recommend copying it though since that makes the original a backup.  Now, load the index.php file in your browser, and you should get a screen like this.

pearmanager

That’s it.  PEAR is now installed and ready to be used.  If you need to make more configuration changes, please consult the PEAR FAQ and Manual.

Setting Up ASP.NET Membership Tables

My hosting provider is deprecating this information because there are newer methods of setting up logins and handling authentication, however, I believe this information is still invaluable to those who haven’t adopted the newer methods and/or can’t keep up with the pace of all the technological changes in the world (or don’t want to).  And in the interest of preserving knowledge, here it is:

The following steps create the full Application Services database schema on our SQL Server database:

Open the command prompt on your local computer, and navigate to:
C:\WINDOWS\Microsoft.NET\Framework\[framework version]

Execute the command:
aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName

Currently, there is no management interface to manage the membership database other than using Visual Web Developer or creating your own application using the membership provider class. Here is an example of how to configure Visual Studio or Visual Web Developer to manage the membership database:

1. Create a web application in Visual Web Developer or Visual Studio.
2. Open the web.config file.
3. The default membership provider uses a connection string called “LocalSqlServer”.  Therefore, replace:

<connectionstrings></connectionstrings>

with:

<connectionstrings>
<remove name="LocalSqlServer"></remove>
<add name="LocalSqlServer" connectionString="Data Source=DBServerName;Integrated Security=false;Initial Catalog=DBName;User ID=DBLogin;Password=DBPassword" providerName="System.Data.SqlClient"></add>
</connectionstrings>

4. Save and close the web.config file.
5. Go to Website menu and run the ASP.NET Configuration tool. This will open the Web Site Administration tool.
6. In the Web Site Administration tool, go to the Security tab.
7. Click on “Select authentication type”.
8. Select “From the internet”. Click the Done button.
9. Create your admin roles and users.
10. Then create access rules.
11. Create a rule that applies to the “Anonymous users” with “Deny” permissions.
12. Create another rule that applies to the admin role you created with “Allow” permissions.

Your application is now ready to use the membership provider, and you can begin creating your log in forms.

Easy Way to GRANT/REVOKE Rights to Tables within a Microsoft SQL Server Database

Yesterday, a customer asked for help setting up an additional database user with only SELECT rights to his database.  He had a lot of tables, so the easiest solution I came up with involved using the sp_MSforeachtable system stored procedure.  Here’s the T-SQL code:

EXEC sp_MSforeachtable
'REVOKE ALL ON ? FROM username'

EXEC sp_MSforeachtable
'GRANT SELECT ON ? TO username'

Make sure you replace username with the database username that you want the rights applied to.